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

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

View Full Document Right Arrow Icon
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. 3 / \ 6 8 / \ / \ 12 10 9 35 / \ / \ / 15 18 77 12 14 (Changes are marked in bold.) 4) Show the array representation of the original heap from question #2. Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 value 1 3 8 12 6
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/22/2010 for the course EECS COP 3502 taught by Professor Guha during the Spring '09 term at University of Central Florida.

Page1 / 2

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online