Recursive data structures
Introduction / Definition
Recursive data structures contain components that can themselves contain smaller structures of the same type. Linked lists, trees, tries, and nested expressions are examples. Their shape often determines the algorithm used to process them. Empty or null references provide termination.
Syntax / Structure / Formula
Node → child/reference → Node ...
Detailed Explanation
A tree node may contain child nodes, and each child is itself a tree. Traversal visits these components systematically.
Example
Example: A binary-tree node contains value, left, and right references.
Output / Result
The children represent smaller binary trees.
Important Points / Notes
- Define empty/base representation.
- Choose an appropriate traversal.
Mini Practice Question
Name two recursive data structures.