Task

Implement a binary tree where each node carries an integer,   and implement:

   pre-order,
   in-order, 
   post-order,     and 
   level-order   traversal. 


Use those traversals to output the following tree:

         1
        / \
       /   \
      /     \
     2       3
    / \     /
   4   5   6
  /       / \
 7       8   9

The correct output should look like this:

preorder:    1 2 4 7 5 3 6 8 9
inorder:     7 4 2 5 1 8 6 9 3
postorder:   7 4 5 2 8 9 6 3 1
level-order: 1 2 3 4 5 6 7 8 9



See also

   Wikipedia article:   Tree traversal.


note
	description : "Application for tree traversal demonstration"
        output      : "[
    	                Prints preorder, inorder, postorder and levelorder traversal of an example binary tree.
    		      ]"
	author	    : "Jascha Grübel"
	date        : "$2014-01-07$"
	revision    : "$1.0$"
 
class
	APPLICATION
 
create
	make
 
feature {NONE} -- Initialization
 
	make
			-- Run Tree traversal example.
		local
			tree:NODE
		do
			create tree.make (1)
			tree.set_left_child (create {NODE}.make (2))
			tree.set_right_child (create {NODE}.make (3))
			tree.left_child.set_left_child (create {NODE}.make (4))
			tree.left_child.set_right_child (create {NODE}.make (5))
			tree.left_child.left_child.set_left_child (create {NODE}.make (7))
			tree.right_child.set_left_child (create {NODE}.make (6))
			tree.right_child.left_child.set_left_child (create {NODE}.make (8))
			tree.right_child.left_child.set_right_child (create {NODE}.make (9))
 
			Io.put_string ("preorder:   ")
			tree.print_preorder
			Io.put_new_line
 
			Io.put_string ("inorder:    ")
			tree.print_inorder
			Io.put_new_line
 
			Io.put_string ("postorder:  ")
			tree.print_postorder
			Io.put_new_line
 
			Io.put_string ("level-order:")
			tree.print_levelorder
			Io.put_new_line
 
		end
 
end -- class APPLICATION