#include <stdio.h>
#include "Tree.h"

void insertTree( TreeElementType E, Tree *T )
/*  pre: T is a binary search tree */
/* post: E is in T and T is still a binary search tree */
/* NB. T is a reference parameter and the tree is changed as a side-effect */
 { if( *T == NULL )
    { *T = (Tree)malloc(sizeof(Node)); /*new leaf*/
      (*T)->left = (*T)->right = (Tree)NULL;                  /*L*/
      TreeElementMove(E, &((*T)->elt));                       /*.*/
    }                                                         /*A*/
   else/*T not NULL*/                                         /*l*/
      if( TreeElementLess( E, (*T)->elt) )                    /*l*/
         insertTree( E, &((*T)->left) );                      /*i*/
      else if( TreeElementLess((*T)->elt, E) )                /*s*/
         insertTree( E, &((*T)->right) );                     /*o*/
   /* else  equal, in this implementation do nothing */       /*n*/
 }/*insertTree*/

/* Insert a New Element E into a Binary Search Tree T. */
