Course contentsShow
← Computer Science
Lesson 452 of 2,87211. Binary TreesFree lesson

Leaves, Internal Nodes, and Edges

Distinguishing between different types of nodes and understanding edges as connections between nodes.

Leaves, Internal Nodes, and Edges

What you'll learn: How to identify the different categories of nodes in a tree and understand edges as the connections between them.


Now that you know about roots, parents, children, and siblings, let's classify nodes by their position and role in the tree structure.

Internal Nodes vs Leaves

Internal nodes (also called non-leaf nodes) are any nodes that have at least one child. They sit somewhere in the middle or top of the tree, acting as connection points between different parts of the structure. The root is typically an internal node unless the tree has only one node.

Leaves (or leaf nodes) are nodes with no children at all. They're the endpoints of the tree—the "dead ends" where branches terminate. Think of them like the leaves on a real tree: they're at the outermost edges with nothing growing beyond them.

Edges: The Connections

An edge is the link or connection between a parent node and one of its children. If you draw a tree diagram, edges are the lines connecting the circles (nodes). Every node except the root has exactly one edge coming into it from its parent.

Analogy: Imagine a family tree. Internal nodes are people who have descendants—parents, grandparents, etc. Leaves are people at the bottom with no children listed. Edges are the literal lines drawn between parent and child on the chart.

Quick Example

In a tree where node A has children B and C, and B has child D:

  • Internal nodes: A, B (they have children)
  • Leaves: C, D (no children)
  • Edges: A→B, A→C, B→D (three connections total)

Key Takeaway: Leaves are nodes without children, internal nodes have at least one child, and edges are the connections linking parents to their children—together they define the tree's structure.