Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BUILD-HEAP(A)
- heap-size[A] ← length[A]
- for i ← length[A]/2 downto 1
- do HEAPIFY(A, i)
- lg n lg n
- ∑ n/(2^h+1)*O(h) = O(n* ∑ O(h/2^h))
- h=0 h=0
- ∞
- ∑ k*x^k = X/(1-x)^2
- k=0
- ∞
- Putting x=1/2, ∑h/2^h = (1/2) / (1-1/2)^2 = 2
- h=0
- lg n ∞
- O(n* ∑ O(h/2^h)) = O(n* ∑ O(h/2^h)) = O(n)
- h=0 h=0
Add Comment
Please, Sign In to add comment