next up previous


CSE 2320 Section 060/061 Spring 1999

Homework 2

Due: February 18, 1999, in class (February 19, 1999, 5:00pm for -10%)

1.
Solve the following recurrence using the iteration method and verify your solution using the substitution method.


\begin{displaymath}T(n) = \left\{ \begin{array}{ll}
\Theta(1) & n = 1 \\
T(n/2) + \Theta(1) & n > 1
\end{array} \right. \end{displaymath}

2.
Solve the following recurrence using the iteration method and verify your solution using the substitution method.


\begin{displaymath}T(n) = \left\{ \begin{array}{ll}
\Theta(1) & n = 1 \\
3T(n-2) + \Theta(1) & n > 1
\end{array} \right. \end{displaymath}

3.
Show the operation of HEAPSORT on the array $A = \langle
5, 2, 6, 9, 7, 4, 8, 4, 3, 10 \rangle$. Specifically, show the binary-tree version of the heap and the array contents after the initial call to BUILD-HEAP and after each call to HEAPIFY in line 5 of the pseudocode on page 147.

4.
Draw a binary tree illustrating the execution of QUICKSORT on the array
$A = \langle
5, 2, 6, 9, 7, 4, 8, 4, 3, 10 \rangle$. Each node contains the subarray $A[p \ldots r]$ passed into the recursive calls to QUICKSORT from their parent node. The root node contains the original array A.

5.
Show the operation of COUNTING-SORT on the array $A = \langle
4, 2, 6, 3, 7, 4, 8, 4, 6, 5 \rangle$. Specifically, first show the Carray after completion of the for loop in lines 6-7 of the pseudocode on page 176. Then, show the B and C array after each iteration through the for loop in lines 9-11.


next up previous