CSCI 2720 Data Structures Spring 2004 News about test 2 --------------------------- SCORES AND GRADE SCALE ----------------------------- Class average raw score was 69 out of 100 points possible. Class averages on questions 1-5, 6, 7, 8, 9, 10, 11, and 12 as raw score % of the possible were: 82%, 74%, 40%, 77%, 89%, 50%, 67%, and 46%, respectively. Highest score in class was 90 points. Grade scale: A >= 85%, B >= 72.5%, C >= 60%, D >= 50%. This will be the percentage-to-grade conversion mapping for all scaled scores in the course. Scaling: calculate the raw score as % out of 90 to obtain the scaled score for test 2. So a raw score of 70 scales to 77.777...%, which lies just below the middle of the B range. ---------------------------------- ANSWERS ------------------------------------- 1(a) T 1(b) F 1(c) F 1(d) T 2(a) F 2(b) F 2(c) T 3 F 4(a) F 4(b) F 4(c) F 4(d) T 5(a) T 5(b) F 5(c) T 6 At the top level, an array 0..9 of column pointers, all null except at 0, 2 and 9; each of those points to the start of a singly linked list containing the non-default values for the corresponding column, e.g., 0[*]-->[ 5, 0,*]-->[57,500,/] 2[*]-->[11, 55,*]-->[22,101,*]-->[90,427,/] 9[*]-->[11, 13,/] 7(a) 1 + 2 + 3 + ... + n = n*(n+1)/2 7(b) { if ( i < j ) return 0.0; return T[ n*(i-1) + (j-1) - i*(i-1)/2 ]; } 8(a) The pairings are ((((NT)S)(IO))(AE)); order doesn't matter, e.g. (TN) and (NT) are equally correct and indicate that T and N are sibling leaves. 8(b) 198 bits. 9 A#LIONS#LITTLE#LITTER (using # for the space symbol) 10 0 1 2 3 4 5 6 +-+-+-+-+-+-+-+ A |1|0|3|2|0|6|0| +-+-+-+-+-+-+-+ B |0|1|0|0|4|0|3| +-+-+-+-+-+-+-+ C |1|2|3|4|5|6|7| +-+-+-+-+-+-+-+ 11(a) First add LC(30)-->(20), then perform double rotation on the path LC(50)-->(6) and RC(6)-->(15). 11(b) First replace (70) by (80) and remove the node LC(90), where (80) was originally. Next, rebalance at (50), which can be done by a single rotation along the edge LC(50)-->(6) or else by a double rotation on the path LC(50)-->(6) and RC(6)-->(15). 12(a) Three splits occur, increasing the height from 2 to 3. The parts which changed are now (root_pointer)-->(35), RC(35)-->(70), LC(35)-->(18), RC(18)-->(25), LC(18)-->(10), RC(25)-->(30), LC(25)-->(20), RC(10)-->(15), and LC(10)-->(5). Note that rotations are never used in a 2-3 tree insertion. 12(b) First replace 70 by 80 in the root, leaving the leaf which contained 80 to now be empty. So the parent and sibling keys are combined into a single node (90,95) with an empty parent node. That is combined with the sibling node (45) and the parent key 80 to form a new 3-node (45,80) with LC(45,80)-->(40), MC(45,80)-->(50,60) and RC(45,80)-->(90,95). The root has become a 2-node, so no more adjustment is needed. In the final tree we have (root_pointer)-->(35), RC(35)-->(45,80), and LC(35)-->(10,18). The subtree at (10,18) is unchanged.