Skip to main content

Command Palette

Search for a command to run...

🌳 Tree Terminology Explained (Data Structures Made Simple)

Updated
3 min read
🌳 Tree Terminology Explained (Data Structures Made Simple)

Trees are one of the most important non-linear data structures in computer science. If you’re learning DSA, Java, Python, or preparing for coding interviews, understanding tree terminology is essential.

In this blog, we’ll break down tree terminology simply and intuitively, with examples you can easily visualise.


🌱 What Is a Tree?

A tree is a hierarchical data structure made up of nodes, where:

  • One node is the root

  • Each node can have children

  • There are no cycles

  • Every node (except the root) has exactly one parent

Real-life examples:

  • File systems

  • Organization charts

  • HTML DOM

  • Decision trees


🧩 Basic Tree Terminology

1️⃣ Node

A node is the basic unit of a tree.
Each node contains:

  • Data (value)

  • References to its child nodes


2️⃣ Root Node

The root is the topmost node of the tree.

  • It has no parent

  • Entry point of the tree


3️⃣ Parent Node

A parent is a node that has one or more child nodes.

Example:

  • N1 is the parent of N2 and N3

4️⃣ Child Node

A child is a node that descends from a parent.

Example:

  • N3 and N2 are children of N1

5️⃣ Sibling Nodes

Nodes that share the same parent are called siblings.


6️⃣Leaf Node (External Node)

A leaf node is a node with no children.


7️⃣Edge

An edge is the connection between two nodes.


8️⃣ Ancestor

An ancestor of a node is any node on the path from the root to that node.

Example:

  • Ancestors of N7: N4, N2, N1


9️⃣ Depth of a Node

The depth of a node is the number of edges from the root to that node.

  • Depth of Node N4 = 2

  • Depth of Root N1 = 0


🔟 Height of a Node

The height of a node is the number of edges on the longest path from that node to a leaf.

  • Height of a leaf node = 0

  • Height of a Node N3=1


1️⃣1️⃣ Height of a Tree

The height of a tree is the height of the root node.


Why Tree Terminology Matters

Understanding tree terminology helps you:

  • Write clean recursive algorithms

  • Understand Binary Trees, BSTs, AVL Trees, and Heaps

  • Solve interview problems confidently

  • Navigate real-world structures like file systems


Happy Learning!

Trees can seem intimidating at first, but a solid grasp of the core terminology makes them far easier to understand. Once these fundamentals are clear, topics like traversals, balanced trees, and even graphs become much more approachable.

If this guide helped you, feel free to share it with fellow DSA learners.
Happy coding! 🌳