{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Heap - Minimum Heap n x Make_heap Insert(x Find_min...

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Minimum Heap n x Make_heap Insert(x) Find_min Del_min (heap sort) " \$ # !# ! ! " \$ ! !# # ! ! n ! ! \$ ! x \$ # Make_heap Insert(x) Find_min Del_min O(nlogn) O(logn) O(1) O(logn) O(n) Make_heap ! ! ! & % ! ! ! ! ! n ! h ! 2h n n 2 n 2 2h+1 -1 h O(log n) 2i+1 i 2 2i i i n 2i > n i n+1 \$ ! & " # & % \$ # " ! ! % & \$ O(1) \$ \$ % \$ &( n 2 %\$ ' n Make_heap % \$ ' &( % Insert(x) Sift_Up Del_min Sift_Down Find_min &\$ Sift_Down \$ O(n) logn logn O(1) Make heap Insert Del_min \$ ! ! ! O(logn) ! # ! ' )\$ % postorder # \$ # &% Make_heap & Insert(x) ' Del_min O(logn) !# )i ! ! \$ i 9=1001 ! ( * ( ! &! O(n) O(logn) O(1) O(logn) O(logn) O(1) O(logn) Insert(x) Find_min Del_min O(nlogn) Make_heap \$ % ! * \$ m O(m) n O(logn) x ' \$ O(1) O(logn) init insert(x) find_mid del_mid n 2 n 2 ' S & L #" &% # # n 2 n 2 ' s =|S| # #" &% O(m) & l =|L| # \$ " O(m)+2·O(m/2)=O(m) \$ make_heap ! O(1) L L L S S L S Init find_mid |S|=|L|+1 |S|=|L| -2 x insert(x) L S n O(3log ) O(log n) 2 |S|=|L|+1 L del_mid O(n) O(logn) O(1) O(1) x ' O(logn) O(logn) init insert(x) find_min find_max del_min del_max # # % \$ & % \$ & % & % \$ & \$ del_min # # ) Sift_Up & \$ \$ % max ' ! & Postorder max O(1) O(1) max ( + O(logn) #+ max ) , O(logn) + max + Make_Heap x \$ % init insert(x) find_min find_max del_min % \$ O(n) max ) * O(logn) * ( #+ Sift_Down ) Sift_Up ) del_max ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online