CSC 17 Test 2 SUMMER 1999

# CSC 17 Test 2 SUMMER 1999 - CSc 17 Test 2 24 June 1999 Page...

This preview shows pages 1–2. Sign up to view the full content.

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<<t; //one-two int *x; x=new int[10]; for(int j=0;j<10;j++) x[j]=j*j; cout<<endl<<(x+3)[4]<<" "<<(x-3)[4]<<endl;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

CSC 17 Test 2 SUMMER 1999 - CSc 17 Test 2 24 June 1999 Page...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online