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: 45, 128, 404, 152, 97, 232, 185, 49 (b) You are asked to Fnd the kth largest element among the given numbers, a 1 , , a n . How fast can you Fnd the kth largest element using a heap? Express worstcase running time in terms of k and n . Assume that your input already satisFes the heap property. 4. Extra Credit: 2 Points Suppose that you are given a sorted sequence of distinct integers { a 1 , a 2 , , a n } in an array representation. Give an O (lg n ) algorithm to determine whether there exists an index i such that a i = i . or example, in {1 , , 2 , 4 , 6 , 19 } , we have a 4 = 4 for i = 4 . In { 3 , 6 , 9 , 15 , 17 } , there is no such i ....
View
Full
Document
 Winter '08
 staff
 Algorithms, Sort

Click to edit the document details