Click to See Complete Forum and Search --> : Heapify: size of subtree


Zulfi Khan2
November 27th, 2005, 06:47 AM
Hi,
I have read in a book(Fundamentals of Algorithm by cormen p=144, MIT Press) that subtree size is 2n/3. When I searched the web I got following :

Left Subtree:
1+....+ 2^(h-1)= 2^h -1
Right Subtree:
1+....+ 2^(h-2)= 2^(h -1)-1
Tree:
1+2^h -1+2^(h -1)-1
=2^h+2^(h-1)-1=n

Subtree size=(2^h-1)/2^h+2^(h-1)-1 * n <2n/3

Can somebody explain me the above?

Zulfi.

suresha_psg
January 3rd, 2006, 09:53 AM
I am not sure. But what am i able to guess from ur message is that its not a complete binary tree. Its almost complete binary tree, thats why height of right subtree is one lessthan the height of left subtree. (h-1 in left and h-2 in right). Can you provide the website also? So that i can be clear.