What is the root of a tree (root)?
The root is the top node of a tree, the one the entire structure starts from.
Characteristics:
- The root has no parent.
- All the other branches of the tree extend from it.
- From the root you can reach any other node by moving down along the edges.
Example:
javascript
A ← root
/ \
B C
/ \
D EHere A is the root of the tree.
Features:
- A tree always has exactly one root.
- If the root is removed, the tree splits into separate subtrees.
- In recursive structures (for example, in search), the work almost always starts at the root.
Summary: The root is the entry point into a tree, the main node from which all the other elements of the structure grow.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.