What is a leaf (leaf)?
A leaf is a tree node that has no children.
Characteristics:
- A leaf is an "end point" of the tree.
- It has no outgoing edges.
- Every path through the tree ends at a leaf.
Example:
javascript
A
/ \
B C
/ \
D EHere D, E, and C are leaves, because there are no other nodes below them.
Properties:
- Every tree has at least one leaf.
- The number of leaves shows how "branched out" a tree is.
Summary: A leaf is a node where the downward path no longer continues, the final node of a tree.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.