Algorithmstrees vocabulary
Tree Structures — Vocabulary and Rooted Trees
TT
Testlaa Team
May 14, 2026•1 min read
A tree is nodes connected without cycles; one root defines parent/child direction. The plural skill trees reminds you that forests and subtrees use the same tools.
Try this in Python
from __future__ import annotations
from dataclasses import dataclass
@dataclass
class TreeNode:
val: int
left: TreeNode | None = None
right: TreeNode | None = None
# Tiny example: root with two children
root = TreeNode(1, TreeNode(2), TreeNode(3))
print(root.val, root.left.val if root.left else None)
Key takeaways
- Edges are directed away from the root in most interview stories.
- Height vs depth: measure from leaves vs from root.
- Subtrees are themselves trees—recursion loves this.
Tags:
Tree structuresPythonStudents
