Repaso
Español
Algorithms & DSCoreALG-46

In a tree data structure, what is a leaf?

Options

  1. The top node
  2. A node with no children (Correct option)
  3. Any node with two children
  4. The connection between nodes

Answer

A node with no children

Why

A tree is made of nodes connected parent → child, with no cycles.

  • Root: the single top node (no parent).
  • Children: nodes directly below a node.
  • Leaf: a node with no children.
  • Height: number of levels from root to the deepest leaf.

Examples: folders on a disk, the HTML DOM, company org charts.

Remember

Root at the top, leaves at the bottom (no children).

Key terms

Practice this question in Repaso