CSE
c17su99t2

# c17su99t2 - CSc 17 Test 2 24 June 1999 Page 1 >ANSWERS<...

• Notes
• nizhes
• 2

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; //49 1 int f,*g,*h,j; f=4; g=&f; h=g; *g=9; *h=8; cout<<f<<" "<<*g; //8 8

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

3. (25 pts) The key idea of the bubble sort involves scanning an array until all its adjacent elements are in order. Write a function,
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern