c109s00t2

# c109s00t2 - CSc 109 Test 2 26 April 2000 >ANSWERS< 1(10 pts...

• Notes
• nizhes
• 4

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

CSc 109 Test 2 26 April 2000 >>>>>>>>>>>>>>>>>>>>>>>>>>ANSWERS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 1. (10 pts) Assume the algorithm discussed in class for balancing a binary tree is used to maintain the two balanced trees below so that an in order traversal of the tree lists the data in ascending order. Explain why both tree (a) and tree (b) are balanced. Draw tree (a) after 15 has been added to tree (a) with balance maintained. Draw tree (b) after 13 has been added to tree (b) with balance maintained. Draw tree (b) after 28 (instead of 13) has been added to tree (b) with balance maintained. Draw tree (b) after 19 (instead of 13 or 28) has been added to tree (b) with balance maintained. (a) 20 / 12 15 / \ 12 20 (b) 15 15 / \ 13 / \ 12 20 ----> 12 20 / / \ / \ / \ 10 17 25 10 13 17 25 / \ / \ / \ / \ 16 18 23 30 16 18 23 30 15 20 / \ 28 / \ 12 20 -----> 15 25 / / \ / \ / \ 10 17 25 12 17 23 30 / \ / \ / / \ / 16 18 23 30 10 16 18 28 15 17 / \ 19 / \ 12 20 ----> 15 20 / / \ / \ / \ 10 17 25 12 16 18 25 / \ / \ / \ / \ 16 18 23 30 10 19 23 30 2. (10 pts) Write the following expressions in postfix form, assuming the usual precedence of operations in C++ and putting blank spaces between each term. a. 2+3+4 > 5*3 && x-5 >= 0 2 3 + 4 + 5 3 * > x 5 - 0 >= && b. (2+3*4)*(5+6-7/8) 2 3 4 * + 5 6 + 7 8 / - * 3. (25 pts)

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

This is the end of the preview. Sign up to access the rest of the document.
• Spring '08
• Kay
• Harry Connick, Jr., ASCII, Bracket, C Sharp

{[ 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