??????????

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;
    }