Trees (Abstract data type)
Trees
- Collection of nodes
- One specialized node is the root.
- A node has one parent (unless it is the root)
- A node has zero or more children. Each node can have any number of children.
- Real-world “trees”:
- Organizational hierarchies
- Some family trees
- Some uses:
- Directory structure on a hard drive
- Sorted collections
| Operations Provided | Efficiency (only if the tree is balanced) |
|---|---|
| Find | O(log n) |
| Add/remove | O(log n) |
Tags
- How to formulaically solve tree challenges?
- Binary Trees
- Binary Search Trees
- Height and Depth of Binary Tree
- Heap (data structure)
depth first searches breadth first searches