criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<stdio.h>
#include<string.h>

#define MAX 500000

typedef struct{
  int key,le,ri;
}Node;
 
Node tree[MAX+1];
int size;
 
void insert(int);
void inorder(int);
void preorder(int);

int main(int argc, char *argv[]){
  int n, i, first;
  first = 1;

  scanf("%d", &n);

  for(i=0;i<=n;i++) 
 tree[i].key = tree[i].le = tree[i].ri = -1;

  size = 0;

  while(n--){
    char str[100];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(first){
        tree[size++].key = in;
        first = 0;
      }
      else insert(in);
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}

void insert(int x){
  int p = 0;
  while(1){
    if(x < tree[p].key){
      if(tree[p].le == -1){
        tree[p].le = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].le;
    }else{
      if(tree[p].ri == -1){
        tree[p].ri = size;
        tree[size++].key = x;
        break;
      }else p = tree[p].ri;
    }
  }
}
 
void inorder(int p){
  if(tree[p].le != -1) inorder(tree[p].le);
  printf(" %d", tree[p].key);
  if(tree[p].ri != -1) inorder(tree[p].ri);
}
 
void preorder(int p){
  printf(" %d", tree[p].key);
  if(tree[p].le != -1) preorder(tree[p].le);
  if(tree[p].ri != -1) preorder(tree[p].ri);
}
 
int main(int argc, char *argv[]){
  int n, i, first;
  first = 1;
  scanf("%d", &n);
  for(i=0;i<=n;i++) tree[i].key = tree[i].le = tree[i].ri = -1;
  size = 0;
  while(n--){
    char str[100];
    scanf("%s", str);
    if(!strcmp(str, "insert")){
      int in;
      scanf("%d", &in);
      if(first){
        tree[size++].key = in;
        first = 0;
      }
      else insert(in);
    }else{
      inorder(0);
      printf("\n");
      preorder(0);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
main.c:80:5: error: redefinition of 'main'
   80 | int main(int argc, char *argv[]){
      |     ^~~~
main.c:17:5: note: previous definition of 'main' with type 'int(int,  char **)'
   17 | int main(int argc, char *argv[]){
      |     ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->right!=NIL)x=x->left;
  return x;
}

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

}

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

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL||z->right==NIL){
    y = z;
}
  else y=treeSuccessor(z);

  if(y->left !=NIL)x=y->left;
  else x=y->right;

  if(x != NIL)x->parent=y->parent;
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent=x;
  else y->parent->right;
  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->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){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    
    printf(" %d",u->key); 
    preorder(u->left);
    preorder(u->right);

  }
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
}
Node treeSearch(Node u, int k){
}
Node treeSuccessor(Node x){
}
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  }
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeofstruct 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){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
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(com[0]=='d'){
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  } 
  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:29:14: error: 'sizeofstruct' undeclared (first use in this function)
   29 |   z = malloc(sizeofstruct node));
      |              ^~~~~~~~~~~~
main.c:29:14: note: each undeclared identifier is reported only once for each function it appears in
main.c:29:26: error: expected ')' before 'node'
   29 |   z = malloc(sizeofstruct node));
      |             ~            ^~~~~
      |                          )
main.c:29:32: error: expected ';' before ')' token
   29 |   z = malloc(sizeofstruct node));
      |                                ^
      |                                ;
main.c:29:32: error: expected statement before ')' token
Language: C

import java.util.Scanner;

class Node {
    public int key;
    public Node left;
    public Node right;

    public Node(int key) {
	this.key = key;
    }
}

class Tree {
    public Node root;

    public void insert(int key) {	
	Node current = null;
	Node next = root;
	while (next != null) {
	    current = next;
	    if (key < next.key) {
		next = next.left;
	    } else {
		next = next.right;
	    }
	}
	
	if (current == null) {
	    root = new Node(key);
	} else if (key < current.key) {
	    current.left = new Node(key);
	} else {
	    current.right = new Node(key);
	}
    }
    private void inorderWalk(Node node) {
	if (node != null) {
	    inorderWalk(node.left);
	    System.out.print(" " + node.key);
	    inorderWalk(node.right);
	}
    }
    public void inorderWalk() {
	inorderWalk(root);
	System.out.println();
    }
    private void preorderWalk(Node node) {
	if (node != null) {
	    System.out.print(" " + node.key);
	    preorderWalk(node.left);
	    preorderWalk(node.right);
	}
    }
    public void preorderWalk() {
	preorderWalk(root);
	System.out.println();
    }
}

class Program {
    public static void main(String[] args) {
	Tree tree = new Tree();

	Scanner scanner = new Scanner(System.in);

	int n = scanner.nextInt();

	for (int i = 0; i < n; i++) {
	    String command = scanner.next();

	    if (command.equals("insert")) {
		int key = scanner.nextInt();
		tree.insert(key);
	    } else {
		tree.inorderWalk();
		tree.preorderWalk();
	    }
	}
    }
}

Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.util.Scanner;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.util.Scanner;
      |            ^
main.c:3:1: error: unknown type name 'class'
    3 | class Node {
      | ^~~~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
    3 | class Node {
      |            ^
main.c:13:1: error: unknown type name 'class'
   13 | class Tree {
      | ^~~~~
main.c:13:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   13 | class Tree {
      |            ^
main.c:60:1: error: unknown type name 'class'
   60 | class Program {
      | ^~~~~
main.c:60:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   60 | class Program {
      |               ^
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

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


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'preorder':
main.c:49:24: error: implicit declaration of function 'preordre'; did you mean 'preorder'? [-Wimplicit-function-declaration]
   49 |     if(u->right != NIL)preordre(u->right);
      |                        ^~~~~~~~
      |                        preorder
main.c: In function 'main':
main.c:63:16: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
   63 |       Node t = treeSearch(root, x);
      |                ^~~~~~~~~~
main.c:63:16: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
main.c:76:7: error: implicit declaration of function 'treeDelete' [-Wimplicit-function-declaration]
   76 |       treeDelete(treeSearch(root, x));
      |       ^~~~~~~~~~
main.c: In function 'insert':
main.c:81:1: error: expected declaration or statement at end of input
   81 | }
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

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


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'preorder':
main.c:49:24: error: implicit declaration of function 'preordre'; did you mean 'preorder'? [-Wimplicit-function-declaration]
   49 |     if(u->right != NIL)preordre(u->right);
      |                        ^~~~~~~~
      |                        preorder
Language: C

#include<stdio.h>
#include<stdlib.h>
?
struct node{
??struct node *right;
??struct node *left;
??struct node *parent;
??int key;
};
typedef struct node * Node;
#define NIL NULL
?
Node root;
?
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){
????x = z;
??} else if(z->key < y->key){
????y->left = z;
??} else{
????y->right = z;
??}
?
}
?
void inorder(Node u){
??if(u!=NIL){
????inorder(u->left);
????printf("%2d",u->key);
????inorder(u->left);
??}
}
void preorder(Node u){
??if(u!=NIL){
????printf("%2d",u->key);
????preorder(u->left);
????preorder(u->right);
??}
}
?
?
int main(){
??int n, i, x;
??char com[20];
?
??scanf("%d", &n);
?
??for ( i = 0; i < n; i++ ){
????scanf("%s", com);
????if ( com[0] == 'i' ){
????scanf("%d", &x);
????insert(x);
????} else if ( com[0] == 'p' ){
????inorder(root);
????printf("\n");
????preorder(root);
????printf("\n");
????}
??}
?
??return 0;
}

Compiler output:
main.c:3:1: error: expected identifier or '(' before '?' token
    3 | ?
      | ^
main.c:12:1: error: expected identifier or '(' before '?' token
   12 | ?
      | ^
main.c:14:1: error: expected identifier or '(' before '?' token
   14 | ?
      | ^
main.c:43:1: error: expected identifier or '(' before '?' token
   43 | ?
      | ^
main.c: In function 'preorder':
main.c:52:1: error: expected expression before '?' token
   52 | ??if(u!=NIL){
      | ^
main.c: At top level:
main.c:58:1: error: expected identifier or '(' before '?' token
   58 | ?
      | ^
Language: C

#include<stdio.h>
#include<stdlib.h>
?
struct node{
??struct node *right;
??struct node *left;
??struct node *parent;
??int key;
};
typedef struct node * Node;
#define NIL NULL
?
Node root;
?
/*Node treeMinimum(Node x){
?
?
}
?
Node treeSearch(Node u, int k){
?
?
}
?
Node treeSuccessor(Node x){
?
?
}
?
void treeDelete(Node z){
??Node y; // node to be deleted
??Node x; // child of y
?
?
?
}
*/
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){
????x = z;
??} else if(z->key < y->key){
????y->left = z;
??} else{
????y->right = z;
??}
?
}
?
void inorder(Node u){
??if(u!=NIL){
????inorder(u->left);
????printf("%2d",u->key);
????inorder(u->left);
??}
}
void preorder(Node u){
??if(u!=NIL){
????printf("%2d",u->key);
????preorder(u->left);
????preorder(u->right);
??}
}
?
?
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 ( com[0] == 'd' ){
????scanf("%d", &x);
????treeDelete(treeSearch(root, x));
????}*/
??}
?
??return 0;
}

Compiler output:
main.c:3:1: error: expected identifier or '(' before '?' token
    3 | ?
      | ^
main.c:12:1: error: expected identifier or '(' before '?' token
   12 | ?
      | ^
main.c:14:1: error: expected identifier or '(' before '?' token
   14 | ?
      | ^
main.c:66:1: error: expected identifier or '(' before '?' token
   66 | ?
      | ^
main.c: In function 'preorder':
main.c:75:1: error: expected expression before '?' token
   75 | ??if(u!=NIL){
      | ^
main.c: At top level:
main.c:81:1: error: expected identifier or '(' before '?' token
   81 | ?
      | ^
main.c:91:3: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   91 | ????/*if ( com[0] == 'f' ){
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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->p=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){
	  inorder(u->left);
	  printf(" %d",u->key);
	  inorder(u->right);
	  }
}
void preorder(Node u){
  if(u!=NIL){
	  printf(" %d",u->key);
	  preorder(u->left);
	  preorder(u->right);
	  }
}


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:52:4: error: 'struct node' has no member named 'p'
   52 |   z->p=y;
      |    ^~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
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){
		x = z;
	} else if(z->key < y->key){
		y->left = z;
	} else{
		y->right = z;
	}
}

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


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 ( com[0] == 'd' ){
    scanf("%d", &x);
    treeDelete(treeSearch(root, x));
    }*/
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:93:18: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
   93 |         Node t = treeSearch(root, x);
      |                  ^~~~~~~~~~
main.c:93:18: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

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->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){
    preorder(u->left);
    preorder(u->right);
  }
  
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'preorder':
main.c:56:7: error: stray '\343' in program
   56 |   if(u<U+3000>!= NIL){
      |       ^~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(){
	Node y = NIL;
  	Node x = root;
  	Node z;

  	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){
		x=z;
	} else if(z->key < y->key){
		y->left = z;
	} else{
		y->right = z;
	}

}

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


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      //treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:44:18: error: 'k' undeclared (first use in this function)
   44 |         z->key = k;
      |                  ^
main.c:44:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>

struct node {
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x) {
  while(x -> left != NIL) {
    x = x -> left;
  }
  return x;
}

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

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

void treeDelete(Node z) {
  Node y;
  Node x;
  
  if(z -> left == NIL || z -> right == NIL) {
    y = z;
  }
  else {
    y = treeSuccessor(z);
  }
  
  if(y -> left != NIL) {
    x = y -> left;
  }
  else {
    x = y -> right;
  }
  
  if(x != NIL) {
    x -> parent = y -> parent;
  }
  
  if(y -> parent == NIL) {
    root = x;
  }
  else if(y == y -> parent -> left) {
    y -> parent -> left = x;
  }
  else {
    y -> parent -> right = 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 -> 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) {
    inorder(u -> left);
    printf(" %d", u -> key);
    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);
    }
  }
}

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(com[0] == 'd') {
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
}

Compiler output:
main.c: In function 'treeDelete':
main.c:80:6: error: 'z' is a pointer; did you mean to use '->'?
   80 |     z.key = y.key;
      |      ^
      |      ->
main.c:80:14: error: 'y' is a pointer; did you mean to use '->'?
   80 |     z.key = y.key;
      |              ^
      |              ->
main.c: At top level:
main.c:135:1: error: return type defaults to 'int' [-Wimplicit-int]
  135 | main() {
      | ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}
*/
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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;



  for(i=0;x != NIL;i++){
    y=x;

    if(z-> < x->key){
      x=x->left;
    }
    else x=x->right;


    z->parent=y;


    if(y==NIL){
      /*
	root=x;
       */
      root=z;
    }

    else if(z->key < y->key) y->left=z;
    else y->right = z;



  }




}

void inorder(Node u){

  if(u != NIL){

    inorder(u->left);

    printf("%d",u->key);

    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL){

    printf("%d",u->key);
    preorder(u->left);
    preorder(u->right);

  }
}


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  
}

Compiler output:
main.c: In function 'insert':
main.c:50:7: error: 'i' undeclared (first use in this function)
   50 |   for(i=0;x != NIL;i++){
      |       ^
main.c:50:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:53:12: error: expected identifier before '<' token
   53 |     if(z-> < x->key){
      |            ^
main.c: In function 'main':
main.c:113:16: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
  113 |       Node t = treeSearch(root, x);
      |                ^~~~~~~~~~
main.c:113:16: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
main.c:126:18: error: passing argument 1 of 'treeDelete' makes pointer from integer without a cast [-Wint-conversion]
  126 |       treeDelete(treeSearch(root, x));
      |                  ^~~~~~~~~~~~~~~~~~~
      |                  |
      |                  int
main.c:30:22: note: expected 'Node' {aka 'struct node *'} but argument is of type 'int'
   30 | void treeDelete(Node z){
      |                 ~~~~~^
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}
*/

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}


void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;



  for(i=0;x != NIL;i++){
    y=x;

    if(z-> < x->key){
      x=x->left;
    }
    else x=x->right;


    z->parent=y;


    if(y==NIL){
      /*
	root=x;
       */
      root=z;
    }

    else if(z->key < y->key) y->left=z;
    else y->right = z;



  }




}

void inorder(Node u){

  if(u != NIL){

    inorder(u->left);

    printf("%d",u->key);

    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL){

    printf("%d",u->key);
    preorder(u->left);
    preorder(u->right);

  }
}


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  return 0;
  
}

Compiler output:
main.c: In function 'insert':
main.c:71:12: error: expected identifier before '<' token
   71 |     if(z-> < x->key){
      |            ^
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}
*/
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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;



  for(i=0;x != NIL;i++){
    y=x;

    if(z-> < x->key){
      x=x->left;
    }
    else x=x->right;


    z->parent=y;


    if(y==NIL){
      /*
	root=x;
       */
      root=z;
    }

    else if(z->key < y->key) y->left=z;
    else y->right = z;



  }




}

void inorder(Node u){

  if(u != NIL){

    inorder(u->left);

    printf("%d",u->key);

    inorder(u->right);
  }

}
void preorder(Node u){
  if(u != NIL){

    printf("%d",u->key);
    preorder(u->left);
    preorder(u->right);

  }
}


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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
  retrun 0;
  
}

Compiler output:
main.c: In function 'insert':
main.c:50:7: error: 'i' undeclared (first use in this function)
   50 |   for(i=0;x != NIL;i++){
      |       ^
main.c:50:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:53:12: error: expected identifier before '<' token
   53 |     if(z-> < x->key){
      |            ^
main.c: In function 'main':
main.c:113:16: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
  113 |       Node t = treeSearch(root, x);
      |                ^~~~~~~~~~
main.c:113:16: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
main.c:126:18: error: passing argument 1 of 'treeDelete' makes pointer from integer without a cast [-Wint-conversion]
  126 |       treeDelete(treeSearch(root, x));
      |                  ^~~~~~~~~~~~~~~~~~~
      |                  |
      |                  int
main.c:30:22: note: expected 'Node' {aka 'struct node *'} but argument is of type 'int'
   30 | void treeDelete(Node z){
      |                 ~~~~~^
main.c:129:3: error: 'retrun' undeclared (first use in this function)
  129 |   retrun 0;
      |   ^~~~~~
main.c:129:9: error: expected ';' before numeric constant
  129 |   retrun 0;
      |         ^~
      |         ;
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;

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

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) return;
  else {
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
    
  }
}

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

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 ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:79:16: error: implicit declaration of function 'treeSearch' [-Wimplicit-function-declaration]
   79 |       Node t = treeSearch(root, x);
      |                ^~~~~~~~~~
main.c:79:16: error: initialization of 'Node' {aka 'struct node *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
main.c:92:18: error: passing argument 1 of 'treeDelete' makes pointer from integer without a cast [-Wint-conversion]
   92 |       treeDelete(treeSearch(root, x));
      |                  ^~~~~~~~~~~~~~~~~~~
      |                  |
      |                  int
main.c:16:22: note: expected 'Node' {aka 'struct node *'} but argument is of type 'int'
   16 | void treeDelete(Node z){
      |                 ~~~~~^
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 treeSu(Node,int);
void insert(int);
void preorder(Node);
void inorder(Node);
int main(){
   int i;
   int n,m;
   char cha[20];
   scanf("%d", &n);
   for(i = 0;i < n;i++)
     scanf("%s",cha);
   if(cha[0] == 'f'){
     scanf("%d",&m);
     if(ts(root,m) != NIL)
       printf("yes\n");
     else
       printf("no\n");
   }
   else if (cha[0] == 'i' ){
     scanf("%d",&m);
     insert(m);
   }
   else if (cha[0] == 'p' ){
     inorder(root);
     printf("\n");
     preorder(root);
     printf("\n");
   }
   return 0;
}

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

void preorder(Node n){
  printf(" %d", n->key);
  if(n->left != NIL)
    preorder(n->left); 
  if(n->right != NIL)
    preorder(n->right);
}
void insert(int n){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = n;
  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; 
}
   
Node treeSu(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return u;
}

Compiler output:
main.c: In function 'main':
main.c:28:9: error: implicit declaration of function 'ts' [-Wimplicit-function-declaration]
   28 |      if(ts(root,m) != NIL)
      |         ^~
main.c:28:20: warning: comparison between pointer and integer
   28 |      if(ts(root,m) != NIL)
      |                    ^~
Language: C

#include<stdio.h>
#include<stdlib.h>

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


typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

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

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y;
  Node x;



}

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

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

#include<stdio.h>
#include<stdlib.h>

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


typedef struct node * Node;
#define NIL NULL

Node root;



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

 
   for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
     
   if ( com[0] == 'i' ){
      scanf("%d", &x);

      insert(x);
    }
     else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    }
  }
 return 0
 
 
}

Node treeMinimum(Node x){


}

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

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y;
  Node x;



}

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

Compiler output:
main.c: In function 'main':
main.c:32:7: error: implicit declaration of function 'insert' [-Wimplicit-function-declaration]
   32 |       insert(x);
      |       ^~~~~~
main.c:35:7: error: implicit declaration of function 'inorder' [-Wimplicit-function-declaration]
   35 |       inorder(root);
      |       ^~~~~~~
main.c:38:7: error: implicit declaration of function 'preorder' [-Wimplicit-function-declaration]
   38 |       preorder(root);
      |       ^~~~~~~~
main.c:42:10: error: expected ';' before '}' token
   42 |  return 0
      |          ^
      |          ;
......
   45 | }
      | ~         
main.c: At top level:
main.c:74:6: warning: conflicting types for 'insert'; have 'void(int)'
   74 | void insert(int k){
      |      ^~~~~~
main.c:32:7: note: previous implicit declaration of 'insert' with type 'void(int)'
   32 |       insert(x);
      |       ^~~~~~
main.c:107:6: warning: conflicting types for 'inorder'; have 'void(struct node *)'
  107 | void inorder(Node u){
      |      ^~~~~~~
main.c:35:7: note: previous implicit declaration of 'inorder' with type 'void(struct node *)'
   35 |       inorder(root);
      |       ^~~~~~~
main.c:114:6: warning: conflicting types for 'preorder'; have 'void(struct node *)'
  114 | void preorder(Node u){
      |      ^~~~~~~~
main.c:38:7: note: previous implicit declaration of 'preorder' with type 'void(struct node *)'
   38 |       preorder(root);
      |       ^~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL

Node root;
/*
  Node treeMinimum(Node x){
  while(x->left != NIL){
  x=x->right;
  }
  return x;
  }
  
  Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
  return u;
  }
  if(k<u->key){
  return treeSearch(u->left,k);
  } else {
  return treeSearch(u->right,k);
  }
  }
  
  Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
  return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
  x=y;
  y=y->parent;
  }
  return y;
  }
  
  void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  
  
  }
*/
void insert(int k,Node z){
  
  Node y = NIL;
  Node x = root;
  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){
    x = z;
  } else if(z->key < y->key){
    y->left = z;
  } else{
    y->right = z;
  }
}

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


int main(){
  int n, i, x;
  char com[20];
  Node z;
  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,z);
      } else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      } else if ( com[0] == 'd' ){
	scanf("%d", &x);
	//treeDelete(treeSearch(root, x));
      }
  }
  
  return 0;
}

Compiler output:
main.c: In function 'insert':
main.c:58:21: error: invalid application of 'sizeof' to incomplete type 'struct Node'
   58 |   z = malloc(sizeof(struct Node));
      |                     ^~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL
 
Node root;
/*
  Node treeMinimum(Node x){
  while(x->left != NIL){
  x=x->right;
  }
  return x;
  }
   
  Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
  return u;
  }
  if(k<u->key){
  return treeSearch(u->left,k);
  } else {
  return treeSearch(u->right,k);
  }
  }
   
  Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
  return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
  x=y;
  y=y->parent;
  }
  return y;
  }
   
  void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
   
   
   
  }
*/
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){
    inorder(u->left);
    printf("%2d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){  
    printf("%2d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node z;
  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 ( com[0] == 'd' ){
    scanf("%d", &x);
    //treeDelete(treeSearch(root, x));
      }
  }
   
  return 0
}

Compiler output:
main.c: In function 'main':
main.c:125:11: error: expected ';' before '}' token
  125 |   return 0
      |           ^
      |           ;
  126 | }
      | ~
Language: C

#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *Node;
#define NIL NULL
 
Node root;
/*
  Node treeMinimum(Node x){
  while(x->left != NIL){
  x=x->right;
  }
  return x;
  }
   
  Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
  return u;
  }
  if(k<u->key){
  return treeSearch(u->left,k);
  } else {
  return treeSearch(u->right,k);
  }
  }
   
  Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
  return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
  x=y;
  y=y->parent;
  }
  return y;
  }
   
  void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
   
   
   
  }
*/
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){
    inorder(u->left);
    printf("%2d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){  
    printf("%2d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node z;
  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 ( com[0] == 'd' ){
    scanf("%d", &x);
    //treeDelete(treeSearch(root, x));
      }
  }
   
  return 0
}

Compiler output:
main.c: In function 'main':
main.c:125:11: error: expected ';' before '}' token
  125 |   return 0
      |           ^
      |           ;
  126 | }
      | ~