UMBC CMSC441, Design & Analysis of Algorithms, Fall 2014


Homework 3

Due Thursday, September 18, 2014

  1. Solve the following recurrence relations using the Master Theorem. State which case of the Master Theorem you used and justify its use.

    1. T(n) = 3 T(n / 2 ) + n2

    2. T(n) = 5 T(n / 2 ) + n2

    3. T(n) = 9 T(n / 3 ) + n2

    4. T(n) = 4 T(n / 2 ) + n log n

  2. 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.

    1. T(n) = 4 T(n / 2 ) + n2 log n.

    2. T(n) = T(n / 3 ) + T(n / 5 ) + n

    3. T(n) = T(n − 1 ) + log n.

  3. 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 ; }


Last Modified: 17 Sep 2014 13:16:24 EDT by Richard Chang
to Fall 2014 CMSC 441 Section 2 Homepage