??java???????????????????????
???????????? ???????[ 2013/2/6 9:48:31 ] ????????
??????????
package binaryTree;
public class TestBinaryTree {
public static void main(String[] args) {
BinaryTree tree = new BinaryTree();
tree.insert("a");
tree.insert("b");
tree.insert("c");
tree.insert("d");
tree.insert("e");
tree.insert("f");
tree.insert("g");
System.out.println("Inorder (sorted): ");
tree.inorder();
System.out.println("postorder: ");
tree.postorder();
System.out.println("preorder: ");
tree.preorder();
System.out.println("the number of nodes is " + tree.getSize());
}
}
??????????????????Ч??????????????????????????????????????????????????????????????????????????κκ????????????????????????????????????????????????????????????????С?????????Ч???????????????????????
????????λ??i??????????????λ??2i+1?????????λ??2i+2?????????????λ??(i-1)/2????
??????????????????????????????????????????????
Move the last node to replace the root;
Let the root be the current node;
while(the current node has children and the current node is smaller than one of its children){
Swap the current node with the larger of its children;
Now the current node is one level down;
}
????????????????????
<STRONG> </STRONG>Let the last node be the current node;
while(the current node is greater than its parent){
Swap the current node with its parent;
Now the current node is one level up;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11