A tree is a hierarchical data structure with a root node and child nodes forming parent-child relationships. Each node has zero or more children, and there's exactly one path between any two nodes. Trees model file systems, HTML DOM, organizational charts, and database indexes.

How Tree Works

File system: root (/) → home → user → documents → file.txt. HTML DOM: html → body → div → p → text. Binary Search Tree: sorted data with O(log n) lookup, insertion, and deletion. Database B-trees: indexes that enable fast queries on billions of rows.

Key Concepts

  • Root — The topmost node — every tree has exactly one root
  • Parent/Child — Each node (except root) has one parent; nodes can have zero or more children
  • Leaf — A node with no children — the endpoints of the tree
  • Depth/Height — Depth: distance from root to a node. Height: longest path from a node to a leaf

Learn Tree — Top Videos

Tree Educators

Gate Smashers
Gate Smashers

@gatesmashers

Data Science

Welcome to Gate Smashers, one of the fastest-growing EdTech communities with 2.6 M+ learners. 🎓 We provide complete lec...

2.6M Subs
2K Videos
13.8K Avg Views
1.58% Engagement
View Profile →
NeetCode
NeetCode

@neetcode

CS

Current NEET and ex-Google SWE, also I love teaching! N.E.E.T. = (Not in education, employment or training) Preparing ...

1.1M Subs
414 Videos
128.4K Avg Views
3.99% Engagement
View Profile →
Greg Hogg
Greg Hogg

@greghogg

Data Science

Today, Greg is driven by a single mission: to help engineers master the complex technical skills required to land roles ...

309K Subs
1.3K Videos
9.1K Avg Views
3.31% Engagement
View Profile →

Frequently Asked Questions

Trees vs graphs?

Trees are a special type of graph: connected, acyclic, with one root. Graphs can have cycles, multiple components, and no root. Trees model hierarchies; graphs model networks.

Want a structured learning path?

Plan a Tree Lesson →