HW12: Exercise 9-4 (P.640)

  1. Define a native C++ class to define an ordered binary tree that stores integer values.
  2. Test your BinaryTree class with the following main program:
        int main()
        {
    	Node root;
    	root.add(120);
    	root.add(43);
    	root.add(437);
    	root.add(17);
    	root.add(57);
    	root.add(766);
    	root.add(24);
    	root.add(88);
    	root.showtree();
    	return 0;
        }
    
  3. The output would look like
    ¡@¡@¡@¡@¡@¡@¡@¡@766
    
    ¡@¡@¡@¡@/
    ¡@¡@¡@¡@437
    ¡@¡@¡@¡@\
    ¡@¡@¡@¡@¡@¡@¡@¡@[]
    /
    120
    \
    ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@88
    ¡@¡@¡@¡@¡@¡@¡@¡@/
    ¡@¡@¡@¡@¡@¡@¡@¡@55
    ¡@¡@¡@¡@¡@¡@¡@¡@\
    ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@[]
    ¡@¡@¡@¡@/
    ¡@¡@¡@¡@43
    ¡@¡@¡@¡@\
    ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@24
    ¡@¡@¡@¡@¡@¡@¡@¡@/
    ¡@¡@¡@¡@¡@¡@¡@¡@17
    ¡@¡@¡@¡@¡@¡@¡@¡@\
    ¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@¡@[]