practice-mid1 - CSci 5421 Practice Questions for Midterm 1...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSci 5421: Practice Questions for Midterm 1 1. Solve the following recurrences using the Master Theorem (MT), if it is applicable, and show your work. If the MT is not applicable, then state clearly why this is so. Assume throughout that T (1) = 1 and that n is a power of 4, 8, and 2, in recurrences (i), (ii), and (iii), respectively. (i) T ( n ) = 4 T ( n/ 4) + √ n log n (ii) T ( n ) = 2 T ( n/ 8) + √ n (iii) T ( n ) = 2 T ( n/ 2) + n/ log n 2. Let A [1 ..n ] be an array storing n distinct integers sorted in increasing order. (Some of the integers could be negative.) Give a divide-and-conquer algorithm to decide if there is an index k such that A [ k ] = k . The output should be “true” if such an index exists, and “false” otherwise. The worst-case running time should be Θ(log n ). Your answer should include: (a) a short description of the main ideas, from which the correctness of your approach should be evident, (b) pseudocode, and (c) an analysis of the running time....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online