# Tree (Data Structure)

> Nodes joined in a branching shape, with one root at the top and no loops.

**Field:** Software Development  
**Category:** Algorithms & Data Structures  
**Also known as:** Tree, Tree Structure

## Think of it like

Think of it like a family tree. One person is at the top, and the kids are below.

## Definition

A tree is a data structure made of nodes joined in a branching shape. It has one node at the top, called the root. Each node can have child nodes below it, and nodes with no children are called leaves. There are no loops: you can never walk back to where you started. Folders on a computer and the HTML of a web page are both trees.

## Example

Jack's computer keeps his files in a tree. The home folder is the root, and each photo is a leaf three folders down.

## Why it matters

Computers store anything with parents and children as a tree. Files, web pages and menus are all trees.

## Common mistake

Picturing the root at the bottom like a real tree. In code the root is drawn at the top.

## Three principles

- **One root.** At the top.
- **Parents and children.** Branching down.
- **No loops.** One path to each node.

## Related terms

- [Binary Tree](https://learn.benibix.com/term/development/binary-tree)
- [Graph (Data Structure)](https://learn.benibix.com/term/development/graph)
- [Data Structure](https://learn.benibix.com/term/development/data-structure)
- [Document Object Model (DOM)](https://learn.benibix.com/term/development/dom)

## Told apart from

- [Tree vs Graph](https://learn.benibix.com/compare/tree-vs-graph): A tree is a graph with rules. It has one root and no loops, so there is one path to each node. A graph may link any node to any other, loops and all.
- [DAG vs Tree](https://learn.benibix.com/compare/directed-acyclic-graph-vs-tree): A tree gives every node just one parent, but a DAG lets a step wait on two or more steps. Both have no loops. Only the DAG can join paths back together.

---

Source: https://learn.benibix.com/term/development/tree
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
