Search⌘ K

Overview of Trees

Explore various tree data structures including binary trees, binary search trees, red-black trees, AVL trees, and 2-3 trees. Understand their definitions, properties such as height and number of nodes, and specific characteristics in C++. This lesson helps you grasp foundational tree types and their importance in efficient coding.

Binary Trees

Definition: A tree where each vertex has two children at most.

Types: Perfect, Full, Complete, Skewed

Total number of nodes: 2(h+1)12^{(h+1)}-1

Total number of leaf nodes: 2hor(n+1)22^{h} or \frac{(n+1)}{2}

Height: log2(n+1)1log_{2}(n+1)-1

%0 1 1 2 2 1->2 3 3 1->3 4 4 2->4 null 5 2->null

Binary Search Trees

Definition: Every node has a value greater to all the node values in its left subtree and has a value less than all the node values in the right subtree. Mathematically,

K ...