Name: _______________________________________________ Honor Code Acknowledgment: __________________________ Random Quiz # 10 CPS 100, Fall 1994 November 9, 1994 problem 1 : Joyce Kilmer In a tree of n nodes, how many edges are there? problem 2 : Kilmer Redux If every non-leaf node in a binary tree has exactly two children and there are n leaves, how many non-leaf nodes are there? problem 3 : Golden Needles A binary search tree is said to be ``right-threaded'' if every NULL right pointer (of a node N) in the tree is replaced by a pointer to the inorder successor of N. For example, in the tree below (root 22) tree | 22 / \ / \ 12 49 / \ / \ 5 15 30 80 / / 1 30 the right-pointer from the node labeled 1 would be replaced by a pointer to node 5 (its inorder successor), the right-pointer of 5 would point to 12, the right pointer of 15 would point to 22, and so on with the deepest 30 right-pointer pointing to the other 30, the shallow 30 pointing to 49 and the 80 right pointer still NULL. Note that the only NULL right-pointer that remains NULL after ``right-threading'' is the right-pointer of the right-most (greatest) leaf since it has no inorder successor. Right a void function RightThread that takes a tree as a parameter and right-threads it. void RightThread(TreeNode * t) You may find it useful to write and call an auxiliary function (hint: the second parameter of the aux function could be the node that a NULL right pointer should point to, initially this would be NULL, but would change in SOME recursive calls).