CPSC 212-301 Answer Key Quiz #1 January 21, 2003 Closed books. Closed notes. Calculators OK. 20 points. 10 minutes. Weight of each question in parentheses. Please use a pencil. For more space, use the back of the sheet. 1. (6) Evaluate each of the following sums. Show how you arrived at your answers. (a) 1 + 2 + 3 + ... + n = n(n+1)/2 (b) 12 + 16 + ... + 4n = 4*(n*(n+1)/2 - 2*3/2) = 2( n*(n+1) - 6 ) = 2*n*(n+1) - 12 2. (4) Simplify each of the following. Assume base-2 logarithms. a) log(B/C * D) = log B - log C + log D b) log (D*(B/(C^16))*D/E) = log D + ( log B - 16 log C) + log D - log E = 2 log D + log B - 16 log C - log E 3. (10) Java code. Assume that a BinaryNode object represents a node, t, of a binary tree. Assume further that t.left and t.right are references to the nodes left and right children. Then answer the questions following. private BinaryNode mystery ( BinaryNode t ) { if ( t != null ) while( t.right != null ) t = t.right; return t; } // mystery __T__ a) (T/F) The code is syntactically correct. _null_ b) If the argument t is null when the method is first invoked, what does the method return? c) If the argument t is not null, and the tree is an arbitrary binary tree, which node of the tree is returned? Be specific. The rightmost node of the tree that does not have a right child (start from root, follow right links, till you reach the node with no right child). _largest_ d) If the argument t is not null, and the tree is a binary search tree, what is the value of the node returned relative to all of the other values (smallest, largest, somewhere in between, average, CBD=cannot be determined without more information). _CBD_ e) If the argument t is not null, and the tree is an arbitrary binary tree, what is the value of the node returned relative to all of the other values (smallest, largest, somewhere in between, average, CBD=cannot be determined without more information).