Section III
7) Given the following list of values: 58, 42, 47, 82, 78, 68, 60, 87, 65, 44
a) Draw the binary search tree that would evolve by inserting the values into the tree in the order in which they are presented
and draw the array representation of this binary search tree.
b) List the values in the order you would have to insert them so as to get a complete binary search tree?
c) List the values in the order you would have to insert them so that an array implementation of a binary search tree would
require the maximum number of elements? How big would this array need to be?
d) What is the difference between balanced and complete binary trees?
e) Express an algorithm that will balance a binary tree.
8) Considering the delete function for binary search trees, specifically the case where the target node has two children:
a) What two nodes did we search for and why?
b) What relationship holds between the next node and the target node.
c) Explain how we ensure that the above relationship holds based on the structure of a Binary Search Tree.
d) Describe the one special case that requires a different method of determining the next node and explain the solution.
e) Write code that changes the links of the tree appropriately, given that you have already set references to all necessary nodes.