Practice Assignment - 5 Tree
Practice Assignment - 5 Tree
1. What is the sequence of nodes visited for the following tree for a preorder, postorder,
and breadth first traversal ?
(a) Write the polynomial as an expression tree that obeys the usual ordering
of operations. Hint: to clarify the ordering for yourself, first write the
expression with brackets indicating the order of operations.
(b) Write the polynomial as postfix expression.
3. Convert the following infix expressions to postfix expressions using binary tree
traversal.
4. Evaluate the following postfix expressions made out of single digit numbers and the
usual integer operators.
5. Prove by induction that an in-order traversal of a binary search tree visits the nodes in
order defined by the keys.
Hint: What is the base case? what is the variable used for the proposition? The number
of nodes of the tree? Something else? What is the induction step?
6. Draw the structure of a binary min-heap after these priorities have been inserted:
10, 12, 1, 14, 6, 5, 8, 15, 3, 9, 7, 4, 11, 13, 2
Also draw the structure after three deleteMin operations.
(a) Draw the resulting BST after 5 is removed, but before any rebalancing takes place.
Label each node in the resulting tree with its balance factor. Replace a node with
both children using an appropriate value from the node's left child.
(b) Now rebalance the tree that results from (a). Draw a new tree for each rotation
that occurs when rebalancing the AVL Tree (you only need to draw one tree that
results from an RL or LR rotation). You do not need to label these trees with
balance factors.