Q10Data Structures
Question
2 marks
Compare tree and graph.
Answer
Trees enforce a strict hierarchical root structure without loops, while graphs allow complex, cyclic networks without roots.
A tree is a specialized, strictly hierarchical non-linear data structure originating from a singular root node, mathematically enforcing a rule where exactly one unique path exists between any two discrete nodes, strictly forbidding cyclic loops. A graph is a generalized network data structure consisting of freely interconnected vertices and edges, readily permitting multiple diverse paths, closed cyclic loops, and possessing no mandatory root node.