SLN_2 - Problem 1 A heap of size n has at most n/2h+1 nodes...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem 1 A heap of size n has at most d n/ 2 h +1 e nodes with height h . Proof : Property 1: Let S h be the set of nodes of height h , subtrees rooted at nodes in S h are disjoint. In other words, we cannot have two nodes of height h with one being an ancestor of the other. Property 2 All subtrees are complete binary trees except for one subtree. Now we derive the bounds of n by N h given these two properties. Let N h be the number of nodes of height h . Since N h - 1 of these subtrees are full, each subtree of them contains exactly 2 h +1 - 1 nodes. One of the height h subtrees may be not full, but contain at least 1 node at its lower level and has at least 2 h nodes. The remaining nodes have height strictly more than h . To connect all subtrees rooted at node in S h , there must be exactly N h - 1 such nodes. The total of nodes is at least ( N h - 1)(2 h +1 - 1)+2 h + N h - 1 while at most N h 2 h +1 - 1, So ( N h - 1)(2 h +1 - 1) + 2 h + ( N h - 1) n N h (2 h +1 - 1) + N h - 1 (1)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/23/2009 for the course CS CMPT 307 taught by Professor A.bulatov during the Spring '09 term at Simon Fraser.

Page1 / 3

SLN_2 - Problem 1 A heap of size n has at most n/2h+1 nodes...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online