CSc 17 Test 2 24 June 1999 Page 1 >>>>>>>>>>>>>>>>ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (15 pts) (a) Using the standard algorithm for building a binary tree for storing numbers in order: (1) show the state of the tree after the numbers 15, 12, 14, 6, and 9 have been added to an empty tree in that order; (2) then show the state of the tree after the numbers 8, 17, and 16 have also been added to the tree in that order. 15 15 / / \ 12 12 17 / \ / \ / 6 14 6 14 16 \ \ 9 9 / 8 (b) Given the binary tree 2 / \ / \ 3 9 / \ / \ 19 -7 8 3 list the numbers resulting from (1) an in-order search of the tree 19 3 -7 2 8 9 3 (2) a post-order search of the tree 19 -7 3 8 3 9 2 (3) a pre-order search of the tree 2 3 19 -7 9 8 3 2. (10 pts) What is the output when the following code is executed? char s[]="one\ntwo\nthree", t[20]; for(int j=0;j<12;j++) t[j]=s[j]; t[3]='-'; t[8]='\0'; cout<next==NULL) return false; Link *temp; temp=list->next; list->next=list->next->next; if(temp!=NULL) delete temp; return true; }