Trees
Tags: #◇Computer Science #◇CCDSALG #◇Trees #◇Conceptual #◇M5
◇Overview
The document defines trees as connected, acyclic, undirected graphs. It introduces rooted trees, binary trees, and complete -ary trees, along with terminology like root, leaf, internal node, ancestor, descendant, depth, and height. It also covers tree traversal algorithms: Breadth-First Search (BFS) and Depth-First Search (DFS), focusing specifically on inorder, preorder, and postorder tree walks.
◇Important Formulas
Leaves in a complete -ary tree of height :
Height of a complete -ary tree with leaves:
Nodes in a complete -ary tree with height :
◇Worked Examples
- Inorder Walk: Visits left subtree, root, then right subtree. Produces a sorted list of keys for a Binary Search Tree.
- Preorder Walk: Visits root, left subtree, then right subtree.
- Postorder Walk: Visits left subtree, right subtree, then root.
◇References & Navigation
- Related Notes: ◇Trees