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
This note was uploaded on 03/16/2010 for the course CSE 101 taught by Professor Staff during the Winter '08 term at UCSD.
 Winter '08
 staff
 Algorithms, Sort

Click to edit the document details