Homework #4 -- due Wednesday Wk 5

# required problems topic
1 CLR Exercise 9.3-7 on page 193 median selection
2 CLR Exercise 4.3-1 on page 75 master method
3 CLR Exercise 4.3-2 on page 75 master method

# suggested problems topic
4 CLR Exercise 9.3-8 on page 193 median selection
5 CLR Exercise 9.3-9 on page 193 median selection
6 CLR Problem 4-1 on page 85 solve recurrences
7 CLR Problem 4-4 on page 86 solve recurrences
8 Baase Exercise 4.49 on page 216 solve recurrence
9* CLR Problem 4-6 on pages 87-88 recursion
10 DPV exercise 2.4 on p.71
Suppose you are choosing between the following three algorithms:
  • Algorithm A solves problems by dividing them into five subproblems of half the size, recursively solving each subproblem, and then combining the solutions in linear time.
  • Algorithm B solves problems of size n by recursively solving two subproblems of size n-1 and then combining the solutions in constant time.
  • Algorithm C solves problems of size n by dividing them into nine subproblems of size n/3, recursively solving each subproblem, and then combining the solutions in O(n2) time.
What are the running times of each of these algorithms (in big-O notation), and which would you choose?
solve recurrences
11 DPV exercise 2.16 on p.73
You are given an infinite array A[*], in which the first n cells contain integers in sorted order and the rest of the cells are filled with ∞.  You are not given the value of n.  Describe an algorithm that takes an integer x as input and finds a position in the array containing x, if such a position exists, in O(log n) time.
algorithm design


Dan Hirschberg
Computer Science Department
University of California, Irvine, CA 92697-3435
dan at ics.uci.edu
Last modified: Jun 18, 2008