UMBC CMSC441, Design & Analysis of Algorithms, Fall 2014
Homework 3
Due Thursday, September 18, 2014
Solve the following recurrence relations using the Master Theorem.
State which case of the Master Theorem you used and justify its use.
T(n) = 3 T(n / 2 ) + n^{2}
T(n) = 5 T(n / 2 ) + n^{2}
T(n) = 9 T(n / 3 ) + n^{2}
T(n) = 4 T(n / 2 ) + n log n
Find upper bounds for the following recurrence relations.
You may use the Master Theorem if it is applicable. If you use the Master Theorem,
state which case of the Master Theorem you used and justify its use. If the Master
Theorem is not applicable, you must use the substitution method or the
iteration/recursion tree method. Make your upper bounds as small as you can.
T(n) = 4 T(n / 2 ) + n^{2} log n.
T(n) = T(n / 3 ) + T(n / 5 ) + n
T(n) = T(n − 1 ) + log n.
Here's a simple recursive sorting algorithm that we will call
VoodooSort:
// Sort array A[] between indices p and r inclusive.
//
VoodooSort (A, p, r) {
// Base Case: use HeapSort
//
if (r - p < 12) {
HeapSort(A, p, r) ;
return ; // add return statement to base case
}
// Break the array into 1st quarter, 2nd quarter and second half
//
n = r - p + 1 ; // number of items in A[p..r] inclusive
q1 = p - 1 + n/4 ; // end of 1st quarter
q2 = q1 + n/4 ; // end of 2nd quarter
// Sort each of the 3 pieces
// using VoodooSort recursively, Insertion-Sort and Heap-Sort
//
VoodooSort (A, p, q1) ;
InsertionSort (A, q1 + 1, q2) ;
HeapSort (A, q2 + 1, r) ;
// Merge the 3 sorted arrays into 1 sorted array
//
Merge (A, p, q1, q2) ; // Merge 1st & 2nd quarter
Merge (A, p, q2, r) ; // Merge 1st & 2nd halves
return ;
}
Write down a recurrence relation for the worst case
running time of VoodooSort. Briefly justify your answer.
Note: You may assume without providing any proof that
the worst case running times of InsertionSort,
HeapSort and Merge are Θ(n^{2}),
Θ(n log n) and Θ(n), respectively.
Prove the best asymptotic upper bound you can on the
worst case running time of VoodooSort.