The problem a BST solves
A sorted array gives O(log n) search but O(n) insert. A linked list gives O(1) insert but O(n) search. A binary search tree tries to get O(log n) for both.
The idea is one rule, applied at every node:
Everything in the left subtree is smaller than this node. Everything in the right subtree is bigger.
Because of that rule, at every node you throw away half the remaining tree. That is binary search, made out of pointers instead of index arithmetic.
The node
struct tnode {
int key;
struct tnode *left;
struct tnode *right;
};
Insert and search
#include <stdio.h>
#include <stdlib.h>