DS0-001 · Question #146
Which of the following is the preferred data structure for storing hierarchical data models?
The correct answer is B. Tree. Trees are the preferred data structure for hierarchical data because they naturally model parent-child relationships with a single root, branching nodes, and leaf nodes - exactly how hierarchies like file systems, org charts, and XML/JSON documents are structured. Stack (A) is…
Question
Which of the following is the preferred data structure for storing hierarchical data models?
Options
- AStack
- BTree
- CQueue
- DGraph
How the community answered
(64 responses)- A5% (3)
- B70% (45)
- C8% (5)
- D17% (11)
Explanation
Trees are the preferred data structure for hierarchical data because they naturally model parent-child relationships with a single root, branching nodes, and leaf nodes - exactly how hierarchies like file systems, org charts, and XML/JSON documents are structured.
- Stack (A) is wrong: it's a linear LIFO structure used for things like undo operations or function call tracking - no branching, no hierarchy.
- Queue (C) is wrong: it's a linear FIFO structure used for task scheduling and buffering - again, purely sequential.
- Graph (D) is wrong: while graphs can represent hierarchies, they're more general (allowing cycles and multiple parents), making them overkill and imprecise for strict hierarchical models.
Memory tip: Think of a family tree - one grandparent (root), children, grandchildren (leaves). That's a tree, not a line (stack/queue) or a web of connections (graph).
Topics
Community Discussion
No community discussion yet for this question.