1#include <stdlib.h>
2#include "bin-trees.h"
3
4tree_ptr
5new_node (int value)
6{
7  tree_ptr node = (tree_ptr) malloc (sizeof (tree_ptr));
8  node->data = value;
9  node->left = NULL;
10  node->right = NULL;
11  return node;
12}
13
14void
15search_tree_insert (tree_ptr *root, int value)
16{
17  if (*root == NULL)
18    *root = new_node (value);
19  else if (value < (*root)->data)
20    search_tree_insert (&((*root)->left), value);
21  else if (value > (*root)->data)
22    search_tree_insert (&((*root)->right), value);
23}
24