Lesson 33 of 50
cBinary Trees – Basic Operations
14 mins
Course progress66%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 33 of 50
c14 mins
Keep these ideas in mind as you work through the lesson.
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 or NULL.inorder(root) – visits nodes in sorted order.Balancing (AVL, Red‑Black) is covered later.