This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 61B Midterm II Summer 2001 CS 61B, Summer 2001 Midterm Exam II Professor Michael Olan Problem 1 (8 points  1 pt each parts a.e., 2 pts part f.) a. Consider the following proof: Suppose f(n) is O(g(n)) . From this we know that g(n) is bigOmega(f (n)) . Thus we can always conclude that when f(n) is O(g(n)) it must also be bigOmega(g(n)) . If you agree justify your answer. If not, give a counterexample. b. A certain sorting algorithm has estimated running time O(N^2) . Does this mean that it always takes longer to sort than an algorithm that is O(N log N) ? Explain your answer. c. What is the overall running time for each of the following algorithms: Algorithm 1 Algorithm 2 1. Read N data items into a Vector 2. Sort the Vector with tree sort 3. Search for a key k with binary search 1. Read N data items into a Vector 2. Search for a key k with linear search d. How would the estimates you calculated in part c. change if the search step is repeated N times? e. In lecture we saw a heapify method with run time bigTheta(N log N). However, it is possible to accomplish this in bigTheta(N) using a "bottom up" heapify method which builds subheaps from the leaves up to the root. Complete the method below so that it is as efficient as possible: protected void heapify( ) { int i; for (______________ ; ________________ ; _______________ ) { reHeapifyDown( i ); } } f. Dr. I.M. Daprof has a policy of assigning "A" grades to the top sqrt(N) students in a class of N students. Always pressed for time, he uses the most efficient algorithm he knows: Sort the gradebook in descending order by numeric score using the fastest sorting algorithm we have seen so far in CS 61B...
View Full
Document
 Spring '01
 Canny
 Computer Science

Click to edit the document details