{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Test2Solution

# Test2Solution - COP 3530 Data Structures and Algorithms...

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

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

View Full Document
COP 3530 Data Structures and Algorithms Summer 2007 Name: ______________________ Question 1: ____ / ____ Question 2: ____ / ____ Question 3: ____ / ____ Question 4: ____ / ____ Total Score: ____ / ____ - 2 -
COP 3530 Data Structures and Algorithms Summer 2007 Name: ______________________ 1. Let the following array of elements [3, 4, 8, 2, 6, 9, 5, 1, 3, 6, 4, 7] represent the elements in a tree. Answer the following questions regarding this array. (a) [10] Initialize a Min Height-Biased Leftist Tree from the array above. Show each step of the initialization process by showing the contents of the queue at each step. (b) [5] Perform three removeMax() operations on the HBLT. Show the resulting tree after each operation. (c) [5] What is the complexity of the initialize and removeMax methods? Justify your answer. - 3 -

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

View Full Document
COP 3530 Data Structures and Algorithms Summer 2007 Name: ______________________ (a) For the sake of space, all steps are not shown. To initialize an HBLT you start with n one node trees and put them in a queue. You continue to remove two trees, meld them, and re-insert them into the queue until only one tree remains. Shown below is the queue after each complete pass through the elements it contains. - 4 - 3 Pass 1 4 8 2 6 9 5 1 3 6 4 7 3 Pass 2 4 2 8 6 9 1 5 3 6 4 7 2 Pass 3 8 3 4 1 5 6 9 3 6 4 7 3 Pass 4 4 6 9 1 2 5 8 3 6 4 7 3 Pass 5 (Final Tree) 4 6 9 1 2 7 8 3 4 6 5
COP 3530 Data Structures and Algorithms Summer 2007 Name: ______________________ (b) To remove the min, break off the two children as trees and meld them together to get the new tree.

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 ]}

### 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