-
大小: 3KB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-02
- 語言: 其他
- 標(biāo)簽: 中位數(shù)??AVL樹??平衡樹??重復(fù)節(jié)點(diǎn)??
資源簡介
能夠在時間復(fù)雜度lg(n)內(nèi)實(shí)現(xiàn)查找中位數(shù)的平衡二叉樹,同時帶重復(fù)節(jié)點(diǎn)計(jì)數(shù)的
代碼片段和文件信息
package?jp.co.worksap.tree;
import?java.util.Iterator;
import?java.util.NoSuchElementException;
/**
?*?
?*?@author?Administrator
?*
?*?@param?
?*/
public?class?AVLTree>?implements?Iterable>?{
private?Entry?root;
private?int?size;
public?boolean?insert(E?element)?{
if?(root?==?null)?{
root?=?new?Entry();
root.element?=?element;
size++;
return?true;
}?else?{
Entry?tmp?=?root;
Entry?ancestor?=?null;
int?comp;
while?(true)?{
comp?=?element.compareTo(tmp.element);
if?(comp?==?0)?{
tmp.elementCount++;
size++;
return?true;
}
if?(tmp.balanceFactor?!=?‘=‘)?{
ancestor?=?tmp;
}
if?(comp?0)?{
tmp.leftchildCount++;
if?(tmp.lef
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????13285??2012-09-17?22:36??tree\AVLTree.java
?????文件????????594??2012-09-16?21:09??tree\Entry.java
?????目錄??????????0??2012-09-17?22:37??tree
-----------?---------??----------?-----??----
????????????????13879????????????????????3
評論
共有 條評論