# Why is heapify O n

Read the entire context:

The children's subtrees each have size at most 2n/3 - the worst case occurs when the last row of the tree is exactly half full

Since the running time is analysed by the number of elements in the tree (), and the recursion steps into one of the subtrees, we need to find an upper bound on the number of nodes in a subtree, relative to , and that will yield that

The worst case of number of nodes in a subtree is when the final row is as full as possible on one side, and as empty as possible on the other. This is called half full. And the left subtree size will be bounded by .

If you're proposing a case with only a few nodes, then that's irrelevant, since all base cases can be considered and ignored.

answered Jul 28 '11 at 13:29

37k77 gold badges6969 silver badges7676 bronze badges

- Whats your biggest business weakness
- Are the oil companies diversifying fast enough
- How do LOD expressions work in Tableau
- Who is Carvajal
- What makes a city cosmopolitan
- Can a baby inside womb feel hungry
- Was Donald Trump popular in high school
- Do you think you will drown
- What is dark field microscopy
- What causes thyroid cancer in young women
- Can I convert PHP to HTML
- Can I become a pediatrician through BHMS
- What went wrong with Orkut
- What was John von Neumanns personality like
- What is love in 2019
- What is the full form of MBS