BinarySearchTree

UI:

  1. Input: the number of nodes you want to insert
  2. Input: the num of each node
  3. Input: a number X that you want to insert
  4. Input: a number that you want to delete

Output:(10 lines)

  • 建立一顆 binary search tree,印出 post-order traversal
  • 印出將這棵樹的 mirror 的 post-order traversal
  • 增加一個數 X 後, 印出 pre-order traversal
  • 印出這棵樹的 height
  • 印出這棵樹現在共有幾個 node
  • 印出這棵樹現在共有幾個 internal node
  • 印出樹中最大值
  • 印出樹中最小值
  • 刪除一個數 Y 後, 印出兩種答案的 pre-order traversal (先印出左子樹最大再印出右子樹最小,如果只有一種答案則答案印兩次)

Functions included:

  1. insert()
  2. find()
  3. print_max()
  4. print_min()
  5. count_node_num()
  6. count_internal_num()
  7. count_height()
  8. preorder_traversal()
  9. inorder_traversal()
  10. postorder_traversal()
  11. mirror()
  12. delete