A tree is a hierarchical structure of nodes connected by edges, with no cycles. Each node holds a value and links to nodes below it. One node sits at the top as the root, the single entry point with no parent.
Parent and child describe a direct link. The node above is the parent, and the nodes hanging off it are its children. A leaf is any node with no children. Internal nodes have at least one child.
You reach every other node by following edges down from the root. Trees model nested containment, such as file systems, HTML documents and org charts. Each step down a search commits to one branch and drops the rest, which is why trees beat flat lists for hierarchical data.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Saved in this browser - sign in to keep your review list.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Keep going - a few more words and AI can grade it.
Interview lens
How interviewers actually use this question
Likely follow-ups
How is a tree different from a general graph?A graph may have cycles, several paths between nodes, or disconnected parts. A tree is connected with no cycles, so exactly one path joins any two nodes.
How would you visit every node in a tree?Name depth-first orders using recursion or a stack, and level-order using a queue. Each visits every node once, so O(n) time.
What you can say
A tree is a hierarchy of nodes joined by edges, with no cycles, where each node holds a value and links to the nodes below it.
At the top is the root, the one node with no parent, and it's the entry point, so you reach every other node by following edges down from it.
Parent and child describe a direct link. The node above is the parent, and the nodes hanging off it are its children.
A leaf is any node with no children, and a node with at least one child is an internal node.
Trees model nested containment, like file systems, HTML documents and org charts, and each step down commits to one branch and drops the rest.
That's why trees beat flat lists for hierarchical data. The catch is one parent per node and no cycles, so data where an item has two parents needs a graph instead.
Weak answers to avoid
Leaves out the no-cycles ruleWithout it you've described a graph. State that there are no cycles and every node but the root has one parent, so one path leads from the root to each node.
Assumes every tree is binaryTwo children is the binary-tree limit, not part of the definition. A general tree node can have any number of children, so define that first.
Says leaves are the nodes on the bottom levelLeaves can sit at different depths. A leaf is any node with no children, wherever it is, and every node with a child is internal.
Recites the terms with no example or reasonInterviewers want to know why trees exist. Map the terms onto a file system, with files as leaves, and say how each step down skips whole branches.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.