node_t
struct node_t *llink, *rlink;
if (rootp == (struct node_t **)0)
return ((struct node_t *)0);
while (*rootp != (struct node_t *)0) { /* T1: */
if (root->left != (struct node_t *)0)
if (root->right != (struct node_t *)0)
struct node_t *left, *right;
if (rootp == (struct node_t **)0)
while (*rootp != (struct node_t *)0) { /* Knuth's T1: */
if (q != (struct node_t *)0) { /* make new node */
q->left = q->right = (struct node_t *)0;
if (rootp == (struct node_t **)0 || *rootp == (struct node_t *)0)
return ((struct node_t *)0);
if (*rootp == (struct node_t *)0)
if ((q = (*rootp)->left) == (struct node_t *)0) /* Left (struct node_t *)0? */
else if (r != (struct node_t *)0) { /* Right link is null? */
if (r->left == (struct node_t *)0) { /* D2: Find successor */
for (q = r->left; q->left != (struct node_t *)0; q = r->left)
free((struct node_t *) *rootp); /* D4: Free node */
if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0)