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: time. A flip indicates a merge operation. So the total running time for m insertions is ∑= + = ≤ ≤ 1 1 ) (lg 2 2 2 k i i i n mO mk m T So the amortized running time for each operation is ) (lg / ) (lg n O m n mO = . c. To delete an element, say x , in i A , first we find the smallest array that is not empty. Assume it is j A . Delete x from i A . If j i ≠ , take an element out of j A and insert it into i A . Whether j i ≠ or not, now the length of j A is 1 2j . Then we divide array j A into j arrays, 1 1 , , ,j A A A L , which are consistent with this data structure. COT 6401 Analysis of Algorithms Homework #4 by Changfu Wu P.2/2 5.22 [Solution] Algorithm: SELECTION( k n , ) 1 ] 1 [ Key candidate ← 2 for 2 ← i to 1 +k n 3 if ] [ i Key candidate 4 ] [ i Key candidate ← 5 return candidate Number of comparisons: k nLower bound of comparisons: k n...
View
Full
Document
This note was uploaded on 10/21/2011 for the course COT 6401 taught by Professor Staff during the Spring '09 term at FAU.
 Spring '09
 STAFF
 Algorithms, Binary Search, Sort

Click to edit the document details