Slot9 Tree Writing
Slot9 Tree Writing
Note: You can select and do some options according to your ability only. We
would like to note you that the more questions you do the better for you in doing
final practical and writing exams.
Writing exercises
1. Give the preorder, inorder, postorder,and level-order traversals of the following
binary trees.
(a) (b)
(c)
2. For each of the following key sequences create the binary search tree obtained
when the keys are inserted one-by-one in the order given into an initially empty
tree:
(1) 4, 3, 1, 11, 5, 9, 2, 6, 15, 12.
(2) 12, 7, 1, 3, 2, 5, 10, 8, 6, 9.
Give the preorder, inorder, postorder,and level-order traversals of the created
binary trees.
In (1) delete keys 2, 3 and 11. In (2) delete keys 5, 6 and 7. After each time of
deleting, give the above traversals.
3. For each of the key sequences in question 2 create the AVL tree obtained
when the keys are inserted one-by-one in the order given into an initially empty
tree.
Give the preorder, inorder, postorder,and level-order traversals of the created
binary trees.
4. The tree (c) in question 1 is height balanced (AVL). Delete the node D and
perfom necessary operations so that the tree is still AVL after deletion.
6. Suppose we have numbers between 1 and 100 in a binary search tree and we
want to search for the number 57 in the tree. Could the following sequence be the
sequence of nodes to be examined?
2, 90, 63, 70, 68, 72, 57