Textbook questions [50 points]
- [15 points]
- [5 pts] Write by hand the definition for Big-Θ five times. Your definition should begin with, "A function f(n) is Θ(g(n))..."
- [5 pts] Show that f(n) = 3(n+5)2 + n is Θ(n2)
- [5 pts] Show that f(n) = lg(n) + n is Θ(n)
- [10 points] Let f(n) and g(n) be asymptotically non-negative functions. This means that, after some point, both f(n) and g(n) are guaranteed to return non-negative values. Use the definition of Big-Θ to show that the function max(f(n), g(n)) is Θ(f(n)+g(n))
- [10 points] Design a divide-and-conquer algorithm for finding the kth smallest element in an unsorted array. For example, for the array A=[20 -47 58 24 -3 11 29 -16] your solution should return -3 for k=3, and 20 for k=5.
You will get at most 7 points for a solution that relies upon sorting or adapts a sorting algorithm. For full points, design an algorithm that does not use sorting at all.
- [15 points] Read IA 2.3-5 for a description of binary search
- [4 pts] Using pseudocode, write a divide-and-conquer solution for binary search.
- [3 pts] What is the recurrence relation that characterizes your recursive algorithm?
- [4 pts] Use your recurrence relation to draw the corresponding recurrence tree. Using your recurrence tree, generate a guess for the running time of your algorithm.
- [4 pts] Verify your guess using the substitution method.
|