Trees: terminology and representation
Tree vocabulary (root, leaf, degree, level, height…) and three ways to store a general tree.
Syllabus says: “Trees: Representation Of Trees”
On this page · 7 sections
A tree is an upside-down coconut tree: ROOT at the top, LEAVES at the bottom. Degree = number of children; height = longest root-to-leaf path.
Your family tree: grandparents at the root, parents below, cousins are siblings' children, and the youngest kids with no children are leaves.
A tree is a finite set of one or more nodes with a specially designated root, where the remaining nodes are partitioned into n ≥ 0 disjoint sets T₁…Tₙ, each of which is itself a tree (subtree).
മുകളിൽ വേര് (root), താഴെ ഇലകൾ (leaves) — തലകീഴായ മരം!
What you will be able to do
- Use tree terminology correctly.
- Represent a general tree as a list, with k-ary nodes, and as left-child right-sibling.
Terminology
| Term | Meaning | In the picture |
|---|---|---|
| Root | the topmost node, with no parent | A |
| Parent / child | a node and the nodes directly below it | B is the parent of E and F |
| Siblings | children of the same parent | E and F |
| Leaf (terminal) | a node with no children | E, F, G |
| Degree of a node | number of its children | deg(B) = 2, deg(C) = 1 |
| Degree of the tree | maximum node degree | 2 |
| Level | root is level 1 (some books use 0); children are one level lower | E is at level 3 |
| Height / depth of tree | maximum level of any node | 3 |
| Ancestors / descendants | all nodes on the path to the root / below a node | ancestors of E: B, A |
| Forest | a set of disjoint trees | remove A → two trees |
Three representations of a general tree
Take a general tree: A has children B, C and D; B has E and F; D has G, H and I.
1. List representation
(A (B (E, F), C, D (G, H, I)))
2. Node with k child fields
Give every node as many link fields as the degree k of the tree. Simple, but wasteful: a tree with n nodes has nk links, of which only n − 1 are used, so n(k − 1) + 1 links are NULL.
3. Left-child right-sibling
Each node keeps just two links: its leftmost child and its next sibling to the right. Every general tree becomes a binary tree this way.
Quick check — can you get them all?
Practice
Every visualizer has a Practice mode: predict the next state before the animation reveals it. You can also work through the topic's question set on the practice page.
Exam-ready summary
- Root, parent, child, sibling, leaf, degree (node / tree), level, height, ancestor, forest.
- List form: (A (B (E, F), C, D (…))).
- k-ary nodes waste n(k − 1) + 1 links.
- Left-child right-sibling → binary tree.
References
- Horowitz, Sahni & Anderson-Freed, Fundamentals of Data Structures in C, 2/e — §5.1 (Introduction to trees)
Explanations on this page are original. Textbook references point to where the standard treatment can be read; no text is reproduced from them.
Prefer revising from notes? Module-wise notes and question papers on Azhimathi Mayam (opens in a new tab)