{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Rec9Sol[1] - Computer Science I Recitation#9(3/26,27 Quick...

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

Computer Science I Recitation #9(3/26,27): Quick Select, Heaps Solution 1) Give two examples of Quick Select running. One were the input array is sorted at the end of the function and one where it is not. Specify the original input for each case and step through the algorithm for both cases, showing the separate outcomes. Run quick select on an array of size 2, storing the elements 2 and 5, looking for the smallest element. Since partition on two elements necessarily sorts the array, we are guaranteed that the array will be sorted when quick select finishes after this call to partition. The example given in the lectures notes (searching for the 4 th smallest element in the given array) is one where quick select does NOT sort the array. Please reference this example. 2) Show the result of inserting the item 7 into the heap shown below: 1 / \ 3 7 / \ / \ 12 6 9 8 / \ / \ / \ / 15 18 10 12 14 77 35 (Changes are marked in bold.) 3) Show the result of removing the minimum element from the original heap in question #2 (without 7) from above.

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

Rec9Sol[1] - Computer Science I Recitation#9(3/26,27 Quick...

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

View Full Document
Ask a homework question - tutors are online