Skip to main content

What is an edge (edge) in a tree?

An edge is a connection between two nodes in a tree: between a parent and its child.

Formally:

An edge is a directed connection of the form

javascript
parent → child

It shows how nodes are connected to each other and defines the structure of the tree.

Example:

javascript
A / \ B C

Here there are two edges:

  • A → B
  • A → C

Properties:

  • If a tree has n nodes, it always has exactly n - 1 edges.
  • Edges can be used to describe paths - sequences of moves from one node to another.

Summary: An edge is the "connection" or "branch" that links nodes together and makes a tree a hierarchical structure rather than just a set of data.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.