Homework 1 - the length of the longest path from this node...

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

View Full Document Right Arrow Icon
W08/CS5592 Homework One Design and Analysis of Algorithms Due: Monday, Feb. 4, 2008 1 Determine and use theta ( Θ ) notation to represent asymptotic upper and lower bounds for each T( n ) of the following functions or recurrence relations. Assume T( n ) is constant for n 4. You need to show clear steps to justify your answers. (a) T( n ) = 2T( n /2) + n 3 (b) T( n ) = 7T( n /3) + n 2 (c) T( n ) = 2T( n /4) + n 2 p ( n ) = a k n k + a k- 1 n k -1 + a k- 2 n k -2 + …+ a 1 n + a 0 is a polynomial function of n , where a k >0. Show that p ( n ) = Θ ( n k ). 3 (a) Exercise 6.1-1 (p129) What are the minimum and maximum number of elements in a heap of height h ? (b) Exercise 6.1-2 (p129) Show that an n -element heap has height lg n . 4 Problem 6.3-3 (p135) Show that there are at most 2 1 + h n nodes of height h in any n -element heap. (Note. The height of a node is the height of the tree rooted at this node. It is equal to
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the length of the longest path from this node to a leaf. ) 5 Suppose the changes of stock price of GOOGLE in the past n days are stored in array A[1. . n ]. We would like to know in which period, the accumulative increase is the largest. For example, in the past 7 days, if the changes are +3, -6, +5, +2, -3, +4, -4, then, the largest increase is from day 3 to day 6. The accumulative increase is 5+2-3+4 = 8. Please design a divide and conquer algorithm that finds the period such that the accumulative increase is the largest. That is to find two indices i and j (1 i j n ) such that = j i k k A ] [ is the largest. Analyze the complexity of your algorithm. 1...
View Full Document

This note was uploaded on 04/12/2008 for the course CS 592 taught by Professor Shen during the Winter '05 term at University of Missouri-Kansas City .

Ask a homework question - tutors are online