資源簡介
能夠在時間復雜度lg(n)內實現查找中位數的平衡二叉樹,同時帶重復節點計數的
代碼片段和文件信息
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
- 上一篇:netassist 網絡調試助手
- 下一篇:線性時間選擇 算法設計
評論
共有 條評論