void Insert(Tree * p, int key, char direction) // precondition: P is not NULL/0. If direction is 'R', // P has a right child; if direction is 'L', // P has a left child. // postcondition: If direction is 'R', a node containing the // value key is created and inserted between P and // P's right child. // If direction is 'L', a node containing the // value key is created and inserted between P and // P's left child. { if (p != NULL) // be safe even with precondition { if (direction == 'R') { p->right = new Tree(key, NULL, p->right); } else if (direction == 'L') { p->left = new Tree(key,p->left); } } }