Data Structures and Algorithms — Trees
Trees are hierarchical data structures with nodes connected by edges. Common types include binary trees, binary search trees, and AVL trees. They're used in databases, file systems, and AI.
// Basic Binary Tree Node
class TreeNode {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
}
const root = new TreeNode(10);
root.left = new TreeNode(5);
root.right = new TreeNode(15);