inserting characters into a binary tree
Question: Show the search tree that would result if the following characters are inserted in the tree from left to right :
k e y b o a r d i n g
Then show the results of different types of traversals of this tree
(preorder, inorder, postorder)..
I have no idea what this tree would look like. Is there rules to how these are put in tree?
First guess is the following:
Code:
k
/ \
e y
/ \ / \
b o a r
/ \ / \
d i n g
Whether or not this tree is created right from the characters given in the order given, I want to also understand the rules for dealing with a heap with characters.
Given this tree I have here, do I leave the letters where they are before giving the traversals OR do I sort first into heap (assuming there is a logic to the "largest" letter) and then show traversal??
Any help here would be greatly appreciated!!!