Lesson 33 of 50 · c
Binary Trees – Basic Operations
Duration: 14 mins
A binary tree node has at most two children: left and right. A common use is a binary search tree (BST) where left < node < right, enabling O(log n) lookup on average.
struct TreeNode {
int key;
struct TreeNode *left;
struct TreeNode *right;
};
Key functions:
insert(root, key)– recursively finds the position.search(root, key)– returns node orNULL.inorder(root)– visits nodes in sorted order.
Balancing (AVL, Red‑Black) is covered later.