skip to content

How do full, complete, perfect and height-balanced binary trees differ from one another?

level: middleimportance: must knowfreq 68%

answer

  1. one word is about arity, one about packing
  2. which one allows a lone child?
  3. does balanced mean symmetric?
  4. perfect forces an exact node count
  5. the inequality-based one is the maintainable one

basics

~20 s

Full means every node has zero or two children. Complete means every level but the last is filled, packing left. Perfect means both, all leaves on one level. Height-balanced only bounds sibling subtree heights, so a balanced tree can look lopsided.

solid answer

~50 s

They constrain different things. **Full** constrains *arity*: no node has exactly one child. **Complete** constrains *packing*: every level except possibly the last is entirely filled, and the last level fills from the left with no gaps. **Perfect** is the intersection taken to the limit — full, complete, and every leaf on the same level, which forces exactly 2^(h+1) - 1 nodes. **Height-balanced** constrains only the *difference* in height between the two subtrees of every node, typically by at most one. Perfect implies complete and full, but complete does not imply full and full does not imply complete. The point candidates miss: balanced does not mean symmetric. A balanced tree can be visibly lopsided and still guarantee what actually matters, a height in Θ(log n) — just with a worse constant than a perfect tree of the same size.

go deeper

for a junior

Learn the four one-line definitions and one counterexample for each pair, especially a tree that is complete but not full. Interviewers accept the definitions only when you can draw them.

for a middle

Explain which implications hold and which fail, and state what each property buys: exact node counts, gap-free flat storage, or a height bound. Naming the payoff is what separates recall from understanding.

for a senior

Argue from the workload: say whether your structure needs the packing guarantee or the height guarantee, and be explicit that a balance condition is a local inequality bought on every write.

for a principal

Frame it as a cost decision: rigid shapes give tight bounds and constant-factor wins but restrict how data may arrive, while balance conditions accept any arrival order and pay for it on every insert.

## Four properties, three different concerns These words get used as if they were degrees on one scale from "messy" to "tidy". They are not. Each one constrains a different aspect of the shape, which is why the implications between them run only one way. | term | what it constrains | what it buys you | |---|---|---| | full | every node has 0 or 2 children | leaves = internal nodes + 1; clean induction proofs | | complete | levels filled top to bottom, last level packed left | height is exactly floor(log2 n); gap-free flat storage | | perfect | full and complete with all leaves on one level | exactly 2^(h+1) - 1 nodes, 2^h leaves | | height-balanced | sibling subtree heights differ by at most a constant | height stays Θ(log n) under arbitrary insert order | ### Full (sometimes called strictly binary) Every node has either two children or none — no node with a lone child. This says nothing about levels. A "caterpillar" shape where the root has one leaf child and one internal child, repeated all the way down, is perfectly full and has height about n/2. So **full does not mean short**, and full trees can be as degenerate as any chain. The property that makes full trees pleasant is the counting identity: in a full binary tree, the number of leaves is always one more than the number of internal nodes. Anything that pairs items until one remains — a merge schedule, a knockout structure — inherits that identity. ### Complete Every level is completely filled except possibly the deepest, and that deepest level is filled contiguously from the left. This is a statement purely about *where the holes are allowed to be*: only at the right end of the bottom row. Two consequences follow. First, a complete tree with n nodes has height exactly floor(log2 n), the smallest height any n-node binary tree can have. Second, the nodes can be laid out in a flat block of n slots, level by level, with no wasted space, and the structure recovered by arithmetic instead of stored links: numbering from 0, the children of slot i are 2i+1 and 2i+2 and the parent of i is floor((i-1)/2); numbering from 1 instead, the children are 2i and 2i+1 and the parent is floor(i/2). That off-by-one between the two numbering schemes is the single most common whiteboard slip on this material — pick a base, write the first two rows out by hand, and check the formulas against them before you use them. Note what completeness is *not*: a complete tree may have a node with exactly one child (the leftmost node of the bottom row can be a lone left child), so complete does not imply full. ### Perfect All internal nodes have two children and all leaves sit on the same level. A perfect tree of height h has 2^h leaves, 2^h - 1 internal nodes and 2^(h+1) - 1 nodes in total. Perfect trees exist only for those exact node counts, which is why they show up in proofs, in counting arguments and in structures deliberately padded to a power of two, but almost never as the shape real data takes. ### Height-balanced A balance condition is a *local* rule enforced at every node — most commonly that the heights of its two subtrees differ by at most one — whose *global* consequence is that the height of the whole tree stays proportional to log2 n. It is the only one of the four properties defined by an inequality rather than by a fill pattern, and the only one you can maintain incrementally under arbitrary insertion order. This is where the misconception lives. "Balanced" does not mean the two sides have equal height, and it does not mean the tree looks symmetric. Take a root whose left subtree has height 2 and whose right subtree has height 1: the difference is 1, the condition holds, and the drawing is visibly lopsided. Repeat that skew at every level and you get a legal balanced tree that is noticeably taller than the complete tree with the same node count — still Θ(log n), just with a larger constant. That is the deal balancing offers: give up the perfect picture, keep the asymptotic guarantee, and get it cheaply on every insert. ## Which property do you actually need? In practice, completeness is a *representation* requirement — it is what makes gap-free flat storage possible. Balance is a *performance* requirement — it is what bounds the cost of every root-to-leaf operation. Full and perfect are mostly *analysis* vocabulary: they make counting arguments and base cases clean. When an interviewer asks which one your structure needs, answering "balanced, because operations cost O(h) and I need h in O(log n)" shows you know why the vocabulary exists rather than merely what the words mean.

  • Sketch a tree that is complete but not full.
    Four nodes: a root with two children, and a single left child under the left child. Every level above the last is filled and the last level packs from the left, so it is complete. But the left child has exactly one child, which violates fullness. This is the standard counterexample showing that completeness constrains where holes may sit, not how many children a node has.
  • Is every full binary tree balanced?
    No. Build a chain where each node has one leaf child and one internal child, repeated down the tree. Every node has zero or two children, so the tree is full, yet its height grows linearly with the node count — roughly n/2. Fullness constrains arity only; it says nothing about how the levels fill, so it offers no height guarantee at all.
  • Why can a complete tree be stored in a flat block of slots while a degenerate one cannot?
    Level-order numbering only wastes no space when the holes are confined to the right end of the bottom row, which is exactly what completeness guarantees. A degenerate chain of n nodes numbered the same way scatters its nodes across roughly 2^n slot positions, since each step down doubles the index. The layout is legal for any shape but only economical for complete ones.

saying these in an interview costs you the question

  • Says balanced means both subtrees have the same height
  • Treats complete and full as synonyms
  • Claims a full binary tree cannot be tall
  • Thinks perfect trees exist for every node count
  • Assumes balanced implies the tree looks symmetric

context