liveBook · Manning

Tree height

As explained in Advanced Algorithms and Data Structures

Tree height is the number of edges on the longest path from a tree's root to a leaf.

Tree height is the number of edges on the longest path from a tree’s root to a leaf. It estimates the work required by operations that descend through a tree: deeper trees require more steps. section 3.5.2 section 5.5.2

Use height to reason about tree structure and performance:

  • Compare a plain binary search tree with a randomized treap by applying identical operation sequences and measuring their heights. section 3.5.2
  • Keep disjoint-set trees shallow by attaching the smaller tree beneath the larger one; the resulting height increases by at most one and remains logarithmically bounded. section 5.6
  • Estimate recursive findPartition cost from the height of the partition tree, while recognizing that an unbalanced tree can produce linear worst-case work. section 5.5.2
Figure 3.17 The height of a Randomized Treap versus a BST. On both data structures the same operations were performed, and the keys are random integers. Notice that the y axis uses a logarithmic scale.

A height comparison chart makes the practical difference between randomized treaps and binary search trees visible across identical operations. section 3.5.2

How Advanced Algorithms and Data Structures covers it

How deep it goes
Defines height and connects it to runtime, then derives logarithmic growth for size-based merges without developing formal proofs.
Examples
Uses profiling charts, recursive findPartition, and balanced versus unbalanced disjoint-set merges as concrete examples.
What you can do after
Evaluate tree implementations by relating height to operation cost, worst-case behavior, and logarithmic performance.
How it connects
Connects tree height with binary search trees, randomized treaps, disjoint sets, union by size, and path compression.

Also explained in

Compare how 3 books explain tree height →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.