You are on page 1of 1

CSCI 3412 Midterm 2 Review Fall 2014

-1-
1. Show the stages of Build-Max-Heap for the following array.
A = !19, 23, 4, 41, 19, 28"
If A is sorted, does the position of the elements in the heap change?

2. Show the first stage of Quicksort on the following array using median-of-three.
A = !19, 23, 4, 41, 19, 28, 25"
What performance would you expect based on your observations?

3. Describe an algorithm that can perform a decrease-key operation on an element in a
minheap in O(lgn) time.

4. Suppose we choose the median of an array A as a pivot for the Quicksort algorithm
and that we can compute the median in O(n) worst-case time. Write the
corresponding recurrence for the running time and solve it.

5. Argue that the running time of quick sort is O(nlgn) if there is a 49 to 1 proportional
split throughout the recursion tree.

6. Describe an O(n) algorithm that rearranges an n-element array of integers so that all
the negative integers precede all others. Justify your running time.

You might also like