This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CIS 435, Fall 2001 First Midterm Exam Prof. Jim Calvin Print Name (last name first): Do not open this exam until instructed to do so. The exam consists of 6 pages, numbered 1 through 6. Before starting to work, make sure that you have all 6 pages. There are five problems, each counting 20 points. You may consult the textbook and your notes, but you may not give or receive assistance from anyone, nor may you use calculators. Write all answers on the exam. I have read and understand all of the instructions above, and I will obey the Academic Honor Code. Signature and Date 1 2 1. Say whether the following statements are true or false. Give a short explanation. a) Express the function n lg n + 3n2 in notation. b) It is possible to modify any sorting algorithm to have a bestcase running time that is O(n). c) Mergesort is faster than Insertionsort for any input array. d) f (n) + g(n) = (min(f (n), g(n))). 3 2. For each of the following pairs of functions, replace the ? with either a , O, or , as appropriate (answering wherever it applies). You must justify your answers to receive credit. a) n1/ lg n =? lg n b) 4lg n =? n c) nlg lg n =? (lg n)1+lg n d) n2 =? 2 lg n 4 3. a) Find the solution to the recurrence T (n) = T (n  1) + lg n with T (0) = 1. b) Give tight bounds for the solution to the recurrence T (n) = 4T (n/16) + n1/4 . 5 4. Consider the following algorithm for determining if an array A contains duplicate numbers: Duplicates(A,n) for i = 1 to n for j = i + 1 to n if A[i] == A[j] then return TRUE return FALSE a) What are the worstcase and bestcase running times of Duplicates? (As usual, give your answers using asymptotic notation.) b) Describe an O(n lg n) algorithm that determines if an array contains duplicate numbers. (You may reference any algorithms we discussed in class in your answer.) 6 5. Use induction to prove that the solution to the recurrence T (n) = T (n  1) + n2 satisfies T (n) = O(n3 ). ...
View
Full
Document
This note was uploaded on 09/29/2010 for the course CS CS 435 taught by Professor Alex during the Spring '09 term at NJIT.
 Spring '09
 ALEX
 Algorithms

Click to edit the document details