Write a program to sort a sequence of numbers using a binary tree (Using
Pointers). A binary tree is a tree structure with only two (possible)
branches from each node.
Each branch then represents a false or true decision. To sort
numbers simply assign the left branch to take numbers less than the node
number and the right branch any other number (greater than or equal to).
To obtain a sorted list simply search the tree in a depth first fashion.
Your program should:
- Create a binary tree structure.
- Create routines for loading the tree appropriately.
- Read in integer numbers terminated by a zero.
- Sort numbers into numeric ascending order.
- Print out the resulting ordered values, printing ten numbers per
line as far as possible.
Typical output should be
The sorted values are:
2 4 6 6 7 9 10 11 11 11
15 16 17 18 20 20 21 21 23 24
27 28 29 30