Language: C

#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;


Node treeSearch(Node x, int k){
  if(x == NIL || k == x->key) return x;
  if(k < x->key) return treeSearch(x->left,k);
  else return treeSearch(x->right,k);

}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
   
  if(y==NIL) root = z;
  else if(z->key<y->key) y->left = z;
  else y->right = z;



}

void inorder(Node u){
 if(u!=NIL){
    if(u->left!=NIL) inorder(u->left);
    
    printf(" %d",u->key);
       
    if(u->right!=NIL) inorder(u->right);
   }
}
void preorder(Node u){
   printf(" %d",u->key);
  if(u!=NIL){
    if(u->left!=NIL) preorder(u->left);
    
    if(u->right!=NIL) preorder(u->right); 
  }
}

Node treeSuccessor(Node x){
  Node y;
  if(x->r != NIL) return treeMinimum(x->r);
  y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    x = y->p;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->l != NIL) x = y->l;
  else x = y->r;
  if(x != NIL) x->p = y->p;
  if(y->p == NIL) root = x;
  else if(y == y->p->l) y->p->l = x;
  else y->p->r = x;
  if(y != z) z->key = y->key;
  }
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else  x = x->r;   
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z; 
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if ( str[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    
  }

  return 0;
}

Compiler output:
main.c: In function 'treeSuccessor':
main.c:68:7: error: 'struct node' has no member named 'r'
   68 |   if(x->r != NIL) return treeMinimum(x->r);
      |       ^~
main.c:68:26: error: implicit declaration of function 'treeMinimum' [-Wimplicit-function-declaration]
   68 |   if(x->r != NIL) return treeMinimum(x->r);
      |                          ^~~~~~~~~~~
main.c:68:39: error: 'struct node' has no member named 'r'
   68 |   if(x->r != NIL) return treeMinimum(x->r);
      |                                       ^~
main.c:69:8: error: 'struct node' has no member named 'p'
   69 |   y = x->p;
      |        ^~
main.c:70:27: error: 'struct node' has no member named 'r'
   70 |   while(y != NIL && x == y->r){
      |                           ^~
main.c:72:10: error: 'struct node' has no member named 'p'
   72 |     x = y->p;
      |          ^~
main.c: In function 'treeDelete':
main.c:80:7: error: 'struct node' has no member named 'l'
   80 |   if(z->l == NIL || z->r == NIL) y = z;
      |       ^~
main.c:80:22: error: 'struct node' has no member named 'r'
   80 |   if(z->l == NIL || z->r == NIL) y = z;
      |                      ^~
main.c:82:7: error: 'struct node' has no member named 'l'
   82 |   if(y->l != NIL) x = y->l;
      |       ^~
main.c:82:24: error: 'struct node' has no member named 'l'
   82 |   if(y->l != NIL) x = y->l;
      |                        ^~
main.c:83:13: error: 'struct node' has no member named 'r'
   83 |   else x = y->r;
      |             ^~
main.c:84:17: error: 'struct node' has no member named 'p'
   84 |   if(x != NIL) x->p = y->p;
      |                 ^~
main.c:84:24: error: 'struct node' has no member named 'p'
   84 |   if(x != NIL) x->p = y->p;
      |                        ^~
main.c:85:7: error: 'struct node' has no member named 'p'
   85 |   if(y->p == NIL) root = x;
      |       ^~
main.c:86:17: error: 'struct node' has no member named 'p'
   86 |   else if(y == y->p->l) y->p->l = x;
      |                 ^~
main.c:86:26: error: 'struct node' has no member named 'p'
   86 |   else if(y == y->p->l) y->p->l = x;
      |                          ^~
main.c:87:9: error: 'struct node' has no member named 'p'
   87 |   else y->p->r = x;
      |         ^~
main.c: At top level:
main.c:91:6: error: redefinition of 'insert'
   91 | void insert(int k){
      |      ^~~~~~
main.c:24:6: note: previous definition of 'insert' with type 'void(int)'
   24 | void insert(int k){
      |      ^~~~~~
main.c: In function 'insert':
main.c:98:4: error: 'struct node' has no member named 'l'
   98 |   z->l = NIL;
      |    ^~
main.c:99:4: error: 'struct node' has no member named 'r'
   99 |   z->r = NIL;
      |    ^~
main.c:103:30: error: 'struct node' has no member named 'l'
  103 |     if(z->key < x->key) x = x->l;
      |                              ^~
main.c:104:16: error: 'struct node' has no member named 'r'
  104 |     else  x = x->r;
      |                ^~
main.c:106:4: error: 'struct node' has no member named 'p'
  106 |   z->p = y;
      |    ^~
main.c:108:29: error: 'struct node' has no member named 'l'
  108 |   else if(z->key < y->key) y->l = z;
      |                             ^~
main.c:109:9: error: 'struct node' has no member named 'r'
  109 |   else y->r = z;
      |         ^~
main.c: In function 'main':
main.c:132:16: error: 'str' undeclared (first use in this function)
  132 |     }else if ( str[0] == 'd' ){
      |                ^~~
main.c:132:16: note: each undeclared identifier is reported only once for each function it appears in