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

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

typedef struct{
  int parent;
  int left;
  int right;
}Node;

Node *T;
int n;

void maigoCenter(void);
int findSibling(int);
int countDegree(int);
int findDepth(int);
int findHeight(int);
void printType(int);

int main(){
  int i, id;

  scanf("%d", &n);

  T = malloc(sizeof(Node) * n);

  for(i=0; i<n; i++){
    T[i].parent = -1;
    scanf("%d%d%d", &id, &T[i].left, &T[i].right);
  }

  maigoCenter();

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, sibling = %d, ", i, T[i].parent, findSibling(i));
    printf("degree = %d, ", countDegree(i));
    printf("depth = %d, ", findDepth(i));
    printf("height = %d, ", findHeight(i));
    printType(i);
  }

  return 0;
}

void maigoCenter(void){
  int i;

  for(i=0; i<n; i++){
    if(T[i].left != -1){
      T[T[i].left].parent = i;
    }
    if(T[i].right != -1){
      T[T[i].right].parent = i;
    }
  }

} 

Compiler output:
/usr/bin/ld: /tmp/ccBrba3D.o: in function `main':
main.c:(.text+0x101): undefined reference to `findSibling'
/usr/bin/ld: main.c:(.text+0x145): undefined reference to `countDegree'
/usr/bin/ld: main.c:(.text+0x165): undefined reference to `findDepth'
/usr/bin/ld: main.c:(.text+0x185): undefined reference to `findHeight'
/usr/bin/ld: main.c:(.text+0x1a5): undefined reference to `printType'
collect2: error: ld returned 1 exit status
Language: C

#include <stdio.h>
#define NIL -1
#define N 100000

int getDepth(int);

struct Node{
  int p;
  int l;
  int r;
  int s;
  int h;
}Node;

struct Node Three[N];

int getDepth(int u){
  int d = 0;

  for(; Three[u].p != NIL; d++){
    u = Three[u].p;
  }

    return d;
  
}

void setHeight(int n){
  int d,i,j;

  for(i = 0; i < n; i++){

    if(Three[i].r == NIL && Three[i].l == NIL){
      Three[i].h == 0;

      for(j = i,d = 1; j != NIL; d++){
	j = Three[j].p;

	if(Three[j].h < d) Three[j].h = d;
      }
    }
  }
}

int main(){

  int i, j;
  int n = 0;
  int v = 0;
  int d = 0;
  int c = 0;
  int l = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    Three[i].p = NIL;
    Three[i].l = NIL;
    Three[i].r = NIL;
    Three[i].s = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&d,&c);

    if(d != NIL && c == NIL){
      Three[v].l = d;
      Three[d].p = v;
    }

    if(c != NIL && d == NIL){
      Three[v].r = c;
      Three[c].p = v;
    }

    if(d != NIL && c != NIL){
      T[v].l = d;
      T[d].p = v;
      T[v].r = c; 
      T[c].p = v;
      T[d].s = c;
      T[c].s = d;
    }
  }
  
  for(i = 0; i < n; i++){

    printf("node %d: parent = %d, sibling = %d, ",i,T[i].p,T[i].s);
    if(Three[i].r == NIL && Three[i].l == NIL){
      printf("degree = 0, ");
    }
    else if(Three[i].r == NIL || Three[i].l == NIL){
      printf("degree = 1, ");
    }
    else{
      printf("degree = 2, ");
    }

    setHeight(n);

    printf("depth = %d, height = %d, ",getDepth(i),Three[i],h);

    if(Three[i].p == NIL){
      printf(" root\n");
    }
    else if(Three[i].l == NIL && Three[i].r == NIL){
      printf(" leaf\n");
    }
    else{
      printf(" internal node\n");
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:78:7: error: 'T' undeclared (first use in this function)
   78 |       T[v].l = d;
      |       ^
main.c:78:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:102:61: error: 'h' undeclared (first use in this function)
  102 |     printf("depth = %d, height = %d, ",getDepth(i),Three[i],h);
      |                                                             ^
Language: C

#include <stdio.h>
#define NIL -1
#define N 100000

int getDepth(int);

struct Node{
  int p;
  int l;
  int r;
  int s;
  int h;
}Node;

struct Node Three[N];

int getDepth(int u){
  int d = 0;

  for(; Three[u].p != NIL; d++){
    u = Three[u].p;
  }

    return d;
  
}

void setHeight(int n){
  int d,i,j;

  for(i = 0; i < n; i++){

    if(Three[i].r == NIL && Three[i].l == NIL){
      Three[i].h == 0;

      for(j = i,d = 1; j != NIL; d++){
	j = Three[j].p;

	if(Three[j].h < d) Three[j].h = d;
      }
    }
  }
}

int main(){

  int i, j;
  int n = 0;
  int v = 0;
  int d = 0;
  int c = 0;
  int l = 0;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    Three[i].p = NIL;
    Three[i].l = NIL;
    Three[i].r = NIL;
    Three[i].s = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d%d",&v,&d,&c);

    if(d != NIL && c == NIL){
      Three[v].l = d;
      Three[d].p = v;
    }

    if(c != NIL && d == NIL){
      Three[v].r = c;
      Three[c].p = v;
    }

    if(d != NIL && c != NIL){
      Three[v].l = d;
      Three[d].p = v;
      Three[v].r = c; 
      Three[c].p = v;
      Three[d].s = c;
      Three[c].s = d;
    }
  }
  
  for(i = 0; i < n; i++){

    printf("node %d: parent = %d, sibling = %d, ",i,Three[i].p,Three[i].s);
    if(Three[i].r == NIL && Three[i].l == NIL){
      printf("degree = 0, ");
    }
    else if(Three[i].r == NIL || Three[i].l == NIL){
      printf("degree = 1, ");
    }
    else{
      printf("degree = 2, ");
    }

    setHeight(n);

    printf("depth = %d, height = %d, ",getDepth(i),Three[i],h);

    if(Three[i].p == NIL){
      printf(" root\n");
    }
    else if(Three[i].l == NIL && Three[i].r == NIL){
      printf(" leaf\n");
    }
    else{
      printf(" internal node\n");
    }
  }

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:102:61: error: 'h' undeclared (first use in this function)
  102 |     printf("depth = %d, height = %d, ",getDepth(i),Three[i],h);
      |                                                             ^
main.c:102:61: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>
#include<stdlib.h>
#define N 100001

typedef struct{
  int parent;
  int left;
  int right;
} Tree;
 
Tree T[N];
 
int sibilings(int);
int degree(int);
int depth_c(int);
int hight(int);
void print(int);
 int sibilings(int a){
  if(T[a].parent == -1){
    return -1;
  }
  else if(T[T[a].parent].left == a){
    return T[T[a].parent].right;
  }
  else return T[T[a].parent].left;
}
 
int degree(int b){
  if(T[b].left ==-1 && T[b].right == -1){
    return 0;
  }
  else if(T[b].left !=-1 && T[b].right != -1){
    return 2;
  }
  else
    return 1;
}
 
int depth_c(int c){
  int count = 0;
  if(T[c].parent == -1){
    return 0;
  }
  else{
    count = depth_c(T[c].parent) + 1;
    return count;
  }
}
 
int hight(int z){
  int ah = 0, bh = 0;
  if(T[z].left != -1){
    ah = hight(T[z].left) + 1;
  }
   if(T[z].right != -1){
    bh = hight(T[z].right) + 1;
  }
   if(ah < bh){
     return bh;
   }
   else
     return ah;
}
 
void print(int f){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",f, T[f].parent, sibilings(f),degree(f));
  printf("depth = %d, height = %d, ",depth_c(f),hight(f));
  if(T[f].parent == B){
    printf("root\n");
  }
  else if(T[f].left == B && T[f].right == B){
    printf("leaf\n");
  }
  else
    printf("internal node\n");
}

main(){
  int i,j,p,l,r,n;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].parent = B;
    T[i].left = B;
    T[i].right = B;
  }
  for(i=0; i<n; i++){
    scanf("%d%d%d",&p,&l,&r);
    T[l].parent = p;
    T[r].parent = p;
    T[p].left = l;
    T[p].right = r;
   }
  for(i=0; i<n; i++){
    print(i);
   }
  return 0;
}
 

Compiler output:
main.c: In function 'print':
main.c:68:21: error: 'B' undeclared (first use in this function)
   68 |   if(T[f].parent == B){
      |                     ^
main.c:68:21: note: each undeclared identifier is reported only once for each function it appears in
main.c: At top level:
main.c:78:1: error: return type defaults to 'int' [-Wimplicit-int]
   78 | main(){
      | ^~~~
main.c: In function 'main':
main.c:82:19: error: 'B' undeclared (first use in this function)
   82 |     T[i].parent = B;
      |                   ^
Language: C

#include <stdio.h>
 
#define M 100001
#define MAX(a,b) ((a) < (b) ? (b) : (a))
 
int par[M],sib[M],deg[M];
int height[M],deph[M];
 
void init(int);
int depth(int,int);
 
int main(void){
  int n,i,id,l,r,t;
 
  scanf("%d" ,&n); 
  init(n);  
 
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&t);
 

    if(l != -1){
      par[l] = id;
      deg[id]++;
    }
    if(t != -1){
      par[t] = id;
      deg[id]++;
    }
    if(l != -1 && t != -1){
      sib[l] = t;
      sib[t] = l;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    deph[i] = depth(i,0);
  }
 
  for(i = 0 ; i < n ; i++){
    printf("node %d: parent = %d, sibling = %d, "
       ,i, par[i], sib[i]);
 
    printf("degree = %d, depth = %d, height = %d, "
       , deg[i], dep[i], height[i]);
     
    if(par[i] == -1){
      printf("root\n");
    }else if(deg[i] != 0){
      printf("internal node\n");
    }else{
      printf("leaf\n");
    }
  }
 
  return 0;
}
 
void init(int n){
  int i;
 
  for(i = 0 ; i < n ; i++){
    par[i] = sib[i] = -1;
    deg[i] = height[i] = 0;
  }
}
 
int depth(int x,int dep){
  height[x] = MAX(height[x],dep);
  if(par[x] == -1){
    return dep;
  }else{
    return depth(par[x],dep+1);
  }
}

Compiler output:
main.c: In function 'main':
main.c:45:18: error: 'dep' undeclared (first use in this function); did you mean 'deph'?
   45 |        , deg[i], dep[i], height[i]);
      |                  ^~~
      |                  deph
main.c:45:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#include <stdlib.h>
#define N 100000
 
typedef struct{
  int id;
  int p;
  int s;
  int c;
  int child[2];
} Tree;
 
int n;
Tree *T;
 
int getdepth(int u){
 
  int d = 0;
 
  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}

int getheight(int x, int y){
  int a=0, b=0;
   
  if(T[x].child[1] != -1){
    a = getheight(T[x].child[1], y+1);
  }  
  if(T[x].child[0] != -1){
    b = getheight(T[x].child[0], y+1);
  } 
  if(T[x].child[0] == -1 && T[x].child[1] == -1){
    return y;
  }
  if(a>=b){
    return a;
  }
  else return b;
}
 
void print(void){
 
  int i,j,flag=0;
 
  for(i=0;i<n;i++){
    flag=0;
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, "T[i].id,T[i].p,T[i].s,T[i].c);

    printf("depth = %d, height = %d, ",getdepth(i),getheight(i,0));

    if(T[i].c == 0 && T[i].p != -1)
      printf("leaf");
    else if(T[i].c != 0 && T[i].p != -1)
      printf("internal node");
    else
      printf("root");
    printf("\n");
  }
}
 
 
int main(void){
 
  int i,j,node,deg;
 
  scanf("%d",&n);
 
  T = malloc(n * sizeof(Tree));
 
  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].s = T[i].child[0] = T[i].child[1] = -1;
    T[i].c = 0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&node);
    scanf("%d %d",&T[node].child[0],&T[node].child[1]);
    T[node].id = node;
    T[T[node].child[0]].p = node;
    T[T[node].child[1]].p = node;
    T[T[node].child[0]].s = T[node].child[1];
    T[T[node].child[1]].s = T[node].child[0];
    if(T[node].child[0] != -1){
      T[node].c = 2;
    }
  }
  print();
  free(T);
  return 0; 
}

Compiler output:
main.c: In function 'print':
main.c:52:63: error: expected ')' before 'T'
   52 |     printf("node %d: parent = %d, sibling = %d, degree = %d, "T[i].id,T[i].p,T[i].s,T[i].c);
      |           ~                                                   ^
      |                                                               )
Language: C

#include <stdio.h>
#include <stdlib.h>
#define N 10000
 
typedef struct{
  int id;
  int p;
  int s;
  int c;
  int child[2];
} Tree;
 
int n;
Tree *T;
 
int getdepth(int u){
 
  int d = 0;
 
  while(T[u].p >= 0){
    u = T[u].p;
    d++;
  }
  return d;
}

int getheight(int x, int y){
  int a=0, b=0;
   
  if(T[x].child[1] != -1){
    a = getheight(T[x].child[1], y+1);
  }  
  if(T[x].child[0] != -1){
    b = getheight(T[x].child[0], y+1);
  } 
  if(T[x].child[0] == -1 && T[x].child[1] == -1){
    return y;
  }
  if(a>=b){
    return a;
  }
  else return b;
}
 
void print(void){
 
  int i,j,flag=0;
 
  for(i=0;i<n;i++){
    flag=0;
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, ",T[i].id,T[i].p,T[i].s,T[i].c);

    printf("depth = %d, height = %d, ",getdepth(i),getheight(i,0));

    if(T[i].c == 0 && T[i].p != -1)
      printf("leaf");
    else if(T[i].c != 0 && T[i].p != -1)
      printf("internal node");
    else
      printf("root");
    printf("\n");
  }
}
 
 
int main(void){
 
  int i,j,node,deg;
 
  scanf("%d",&n);
 
  T = malloc(n * sizeof(Tree));
 
  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].s = T[i].child[0] = T[i].child[1] = -1;
    T[i].c = 0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&node);
    scanf("%d %d",&T[node].child[0],&T[node].child[1]);
    T[node].id = node;
    T[T[node].child[0]].p = node;
    T[T[node].child[1]].p = node;
    T[T[node].child[0]].s = T[node].child[1];
    T[T[node].child[1]].s = T[node].child[0];
    if(T[node].child[0] != -1){
      T[node].c = 2;
    }
  }
  print();
  free(T);
  return 0; 

Compiler output:
main.c: In function 'main':
main.c:94:3: error: expected declaration or statement at end of input
   94 |   return 0;
      |   ^~~~~~
Language: C

#include <stdio.h>
#define N 25
 
typedef struct{
  int id;
  int sibling;
  int parent;
  int right;
  int left;

} Node;
 
int main(){
  int i, j, n;
  int id, right, left, depth, parent;
  Node node[N];
 
  scanf("%d", &n);
 
  for(i = 0; i < n;  i++){
    node[i].sibling = -1;
    node[i].parent = -1;
  }
 
  for( i = 0; i < n; i++){
    scanf("%d%d%d", &id, &left, &right);
 
    node[id].id = id;
    node[id].right = right;
    node[id].left = left; 

    if(right != -1 || left != -1){
      node[right].parent = id;
      node[left].parent = id;
      node[right].sibling = left;
      node[left].sibling = right;
    }

Compiler output:
main.c: In function 'main':
main.c:37:5: error: expected declaration or statement at end of input
   37 |     }
      |     ^
main.c:37:5: error: expected declaration or statement at end of input
Language: C

#include<stdio.h>

typedef struct{
  int id;
  int r;
  int l;
  int deg;
  int s;
  int parent;
  int dep;
  int h;
}Tree;

main(){
  int a,i,j,g,x,y,count,max;
  Tree node[25];
  scanf("%d",&g);
  for(i=0;i<g;i++){
    scanf("%d",&a);
    node[a].id=a;
    scanf("%d%d",&node[a].l,&node[a].r);
  }
  
   for(i=0;i<g;i++){
     count=0;
    for(j=0;j<g;j++){
      if(node[i].id==node[j].l || node[i].id == node[j].r){
	  node[i].parent=node[j].id;
          count++;
	  break;
      }
      if(count>0)break;
      else node[i].parent = -1;
    }}

   for(i=0;i<g;i++){
count=0;
     for(j=1;j<g;j++){
       if(node[i].parent == -1)node[i].s =-1;
       else if(node[i].parent == node[j].parent){
	 node[i].s =node[j].id;
	 node[j].s =node[i].id;
count++;
	 break;
        }
        }
if(count==0)node[i].s=-1
}

   for(i=0;i<g;i++){
     if(node[i].l==-1 && node[i].r==-1)node[i].deg=0;
     else if(node[i].l >=0 && node[i].r>=0)node[i].deg=2;
     else node[i].deg=1;
   }

   for(i=0;i<g;i++){
    node[i].dep=0;
    if(node[i].parent==-1)continue;
    if(node[i].parent>=0)node[i].dep++;
    x=node[i].parent;
    while(1){
      if(node[x].parent>=0){
	node[i].dep++;
	x = node[x].parent;
      }
      else  break;
    }
  }
   max = -999;
   for(i=0;i<g;i++){
     if(max<node[i].dep)max=node[i].dep;}

   for(i=0;i<g;i++){
     node[i].h=0;
     if(node[i].deg==0)continue;
     else{
       x = node[i].l;
       y = node[i].r;
       while(1){
	 if(node[x].deg>0 && node[y].deg>0){
	   node[i].h = max - node[i].dep;
	 break;
	 }
	 else if(node[x].deg==0 && node[y].deg == 0){
	   node[i].h++;
	   break;
	 }
	 else if(node[x].deg>0 && node[y].deg == 0){
	   node[i].h++;
	   x = node[x].l;
	   y = node[x].r;
	 }
	  else if(node[x].deg==0 && node[y].deg>0){
	   node[i].h++;
	   x = node[y].l;
	   y = node[y].r;
	 }
       }}}
	 
       
   for(i=0;i<g;i++){
     printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",node[i].id,node[i].parent,node[i].s,node[i].deg,node[i].dep,node[i].h);
   if(node[i].dep==0)printf("root\n");
   else if(node[i].h==0)printf("leaf\n");
   else printf("internal node\n");
   
   }
   return 0;
}

Compiler output:
main.c:14:1: error: return type defaults to 'int' [-Wimplicit-int]
   14 | main(){
      | ^~~~
main.c: In function 'main':
main.c:47:25: error: expected ';' before '}' token
   47 | if(count==0)node[i].s=-1
      |                         ^
      |                         ;
   48 | }
      | ~
Language: C

int main(void){
 
  int i,node,c,l,r;

  scanf("%d",&n);
 
  T = malloc(n * sizeof(Tree));
 
  for(i=0;i<n;i++){
    T[i].id = T[i].p = T[i].s = T[i].l = T[i].r = -1;
    T[i].c = 0;
  }
 
  for(i=0;i<n;i++){
    c = 0;
    scanf("%d",&node);
    scanf("%d %d",&T[node].l,&T[node].r);
    T[node].id = node;

    if(T[node].l != -1 && T[node].r != -1){
    T[T[node].l].p = T[T[node].r].p = node;
    T[T[node].l].s = T[node].r;
    T[T[node].r].s = T[node].l;
    }



    if(T[node].l == -1) c++;
    if(T[node].r == -1) c++;

    if(c == 0) T[node].c = 2;
    else if(c == 1) T[node].c = 1;
    else T[node].c = 0;

  }
  print();
  free(T);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | int main(void){
main.c:5:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |   scanf("%d",&n);
      |   ^~~~~
main.c:5:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:5:15: error: 'n' undeclared (first use in this function)
    5 |   scanf("%d",&n);
      |               ^
main.c:5:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:7:3: error: 'T' undeclared (first use in this function)
    7 |   T = malloc(n * sizeof(Tree));
      |   ^
main.c:7:7: error: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
    7 |   T = malloc(n * sizeof(Tree));
      |       ^~~~~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
  +++ |+#include <stdlib.h>
    1 | int main(void){
main.c:7:7: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
    7 |   T = malloc(n * sizeof(Tree));
      |       ^~~~~~
main.c:7:7: note: include '<stdlib.h>' or provide a declaration of 'malloc'
main.c:7:25: error: 'Tree' undeclared (first use in this function)
    7 |   T = malloc(n * sizeof(Tree));
      |                         ^~~~
main.c:36:3: error: implicit declaration of function 'print' [-Wimplicit-function-declaration]
   36 |   print();
      |   ^~~~~
main.c:37:3: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   37 |   free(T);
      |   ^~~~
main.c:37:3: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:37:3: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:37:3: note: include '<stdlib.h>' or provide a declaration of 'free'
Language: C

#include<stdio.h>
#define NIL -1

int depth(int );
int sibling(int );
int height(int );
void output(int );


typedef struct{
  int parent;
  int left;
  int right;
}vertex;

int mae,a,b;
int Node[25],D[25];
int ver[25];
vertex Tree[25],child;

int main(){
  
  int i,n,l,r;
  
  scanf("%d",&n);
  
  for( i=0 ; i<n ; i++){
    Tree[i].parent = Tree[i].left = Tree[i].right = NIL;
  }
  for( i=0 ; i<n ; i++){
    scanf("%d",&ver[i]);
    
    if(i == 0){
      Tree[ ver[i] ] .parent= NIL;
    }

    scanf("%d",&Tree[ver[i]].left);
    scanf("%d",&Tree[ver[i]].right);
    
    l = Tree[ver[i]].left;
    r = Tree[ver[i]].right;
    Tree[l].parent = Tree[r].parent = ver[i];
  }

  for( i=0 ; i<n ; i++){
    D[i] = depth(i);
  }
  for( i=0 ; i<n ; i++){
    output(i);
  }
  return 0;
}

int depth(int i){
  int d =0;
  while(1){
    if(Tree[i].parent == NIL)
      break;
    d++;
    i = Tree[i].parent;
  }
  return d;
}

int heght(int i){
  int RightHeight=0,LeftHeight=0;
  
  if( Tree[i].left == NIL && Tree[i].right == NIL )return 0;
  if(Tree[i].left!=NIL)LeftHeight = height(Tree[i].left)+1;
  if(Tree[i].right!=NIL)RightHeight = height(Tree[i].right)+1;
  
  if(RightHeight>LeftHeight)return RightHeight;
  else return LeftHeight;
} 

int sibling(int i){
  int s;
  s = Tree[i].parent;
  if( s == -1)return NIL;
  if( i == Tree[s].left)return Tree[s].right;
  else if(i == Tree[s].right)return Tree[s].left;
  else if( Tree[s].right == NIL && Tree[s].left == NIL)return NIL;
}

void output(int i){
  int d;
  
  printf("node %d: parent = %d, sibling = %d, degree = ",i,Tree[i].parent,sibling(i));
  if(Tree[i].left ==NIL && Tree[i].right ==NIL)printf("0, ");
  else if(Tree[i].left == NIL || Tree[i].right == NIL)printf("1, ");
  else printf("2, ");
 
  printf("depth = %d, height = %d, ",D[i],height(i));
 
  if(Tree[i].left == NIL && Tree[i].right == NIL && Tree[i].parent!=NIL)printf("leaf\n");
  else if(Tree[i].parent == NIL)printf("root\n");
  else printf("internal node\n");
}

Compiler output:
/usr/bin/ld: /tmp/ccmC6EYZ.o: in function `heght':
main.c:(.text+0x45c): undefined reference to `height'
/usr/bin/ld: main.c:(.text+0x4ae): undefined reference to `height'
/usr/bin/ld: /tmp/ccmC6EYZ.o: in function `output':
main.c:(.text+0x712): undefined reference to `height'
collect2: error: ld returned 1 exit status
Language: C

 
int main(void) {
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < MAX_N; i++) {
        T[i].p = NIL;
        T[i].l = NIL;
        T[i].r = NIL;
    }
 
    for (i = 0; i < n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        T[id].l = left;
        T[id].r = right;
        if (left != NIL) T[left].p = id;
        if (right != NIL) T[right].p = id;
    }
 
    int r;
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }
 
    setDepth(r, 0);
    setHeight(r);
 
    for (i = 0; i < n; i++) {
        print(i);
    }
 
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:4:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    4 |     scanf("%d", &n);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | 
main.c:4:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    4 |     scanf("%d", &n);
      |     ^~~~~
main.c:4:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:5:21: error: 'MAX_N' undeclared (first use in this function)
    5 |     for (i = 0; i < MAX_N; i++) {
      |                     ^~~~~
main.c:5:21: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:9: error: 'T' undeclared (first use in this function)
    6 |         T[i].p = NIL;
      |         ^
main.c:6:18: error: 'NIL' undeclared (first use in this function)
    6 |         T[i].p = NIL;
      |                  ^~~
main.c:25:5: error: implicit declaration of function 'setDepth' [-Wimplicit-function-declaration]
   25 |     setDepth(r, 0);
      |     ^~~~~~~~
main.c:26:5: error: implicit declaration of function 'setHeight' [-Wimplicit-function-declaration]
   26 |     setHeight(r);
      |     ^~~~~~~~~
main.c:29:9: error: implicit declaration of function 'print' [-Wimplicit-function-declaration]
   29 |         print(i);
      |         ^~~~~
Language: C

#include <stdio.h>
#define NIL -1
#define MAX_N 30
typedef struct node_ {
    int p;
    int l;
    int r;
} Node;
 
Node T[MAX_N];
int D[MAX_N], H[MAX_N];
 
void setDepth(int u, int d) {
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}
 
int setHeight(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].l != NIL) {
        h1 = setHeight(T[u].l) + 1;
    }
    if (T[u].r != NIL) {
        h2 = setHeight(T[u].r) + 1;
    }
 
    if (h1 >= h2) {
        return H[u] = h1;
    } else {
        return H[u] = h2;
    }
}
 
int getSibling(int u) {
    if (T[u].p == NIL) return NIL;
    if (T[T[u].p].l != u && T[T[u].p].l != NIL) {
        return T[T[u].parent].l;
    }
    if (T[T[u].p].r != u && T[T[u].p].r != NIL) {
        return T[T[u].p].r;
    }
    return NIL;
}
 
void print(int u) {
    printf("node %d: ", u);
    printf("parent = %d, ", T[u].p);
    printf("sibling = %d, ", getSibling(u));
 
    int deg = 0;
    if (T[u].l != NIL) deg++;
    if (T[u].r != NIL) deg++;
    printf("degree = %d, ", deg);
 
    printf("depth = %d, ", D[u]);
    printf("height = %d, ", H[u]);
 
    if (T[u].p == NIL) {
        printf("root\n");
    } else if (T[u].l == NIL && T[u].r == NIL) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}
 
int main(void) {
    int i, n;
    scanf("%d", &n);
    for (i = 0; i < MAX_N; i++) {
        T[i].p = NIL;
        T[i].l = NIL;
        T[i].r = NIL;
    }
 
    for (i = 0; i < n; i++) {
        int id, left, right;
        scanf("%d %d %d", &id, &left, &right);
        T[id].l = left;
        T[id].r = right;
        if (left != NIL) T[left].p = id;
        if (right != NIL) T[right].p = id;
    }
 
    int r;
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) r = i;
    }
 
    setDepth(r, 0);
    setHeight(r);
 
    for (i = 0; i < n; i++) {
        print(i);
    }
 
    return 0;
}

Compiler output:
main.c: In function 'getSibling':
main.c:39:22: error: 'Node' {aka 'struct node_'} has no member named 'parent'
   39 |         return T[T[u].parent].l;
      |                      ^
Language: C

#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct{
  int parent,left,right;
}Node;
Node T[MAX];
int n,D[MAX],H[MAX];

void print(int u){
  int i,c,deg=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left!=NIL)deg++;
  if(T[u].right!=NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL)printf("root\n");
  else if(T[u].left == NIL && T[u].right == NIL)printf("leaf, ");
  else printf("internal node\n");

}

int setHeight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL)
    h1=setHeight(T[u].left) + 1;
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL)return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    returnT[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    returnT[T[u].parent].right;
  return NIL;
}

void setDepth(int u,int d){
  if(u==NIL)return;
  D[u] = d;
  if(T[u].r != NIL)setDepth(T[u].right, d+1);
  if(T[u].l != NIL)setDepth(T[u].left, d+1);
}

int main(){
  int i,v,l,r,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++)T[i].parent=NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
T[v].left=l
T[v].right=r
  if(l!=NIL)T[l].parent=v;
 if(r!=NIL)T[r].parent=v;
  }
  for(i=0;i<n;i++)if(T[i].parent==NIL)root=i;

  setDepth(root,0);
  setHeight(root,0);

  for(i=0;i<n;i++)print(i);

  return 0;
}

Compiler output:
main.c: In function 'print':
main.c:15:27: error: implicit declaration of function 'getSibling'; did you mean 'getline'? [-Wimplicit-function-declaration]
   15 |   printf("sibling = %d, ",getSibling(u));
      |                           ^~~~~~~~~~
      |                           getline
main.c:22:10: error: 'Node' has no member named 'p'
   22 |   if(T[u].p == NIL)printf("root\n");
      |          ^
main.c: In function 'getSibling':
main.c:40:5: error: 'returnT' undeclared (first use in this function)
   40 |     returnT[T[u].parent].left;
      |     ^~~~~~~
main.c:40:5: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'setDepth':
main.c:49:10: error: 'Node' has no member named 'r'
   49 |   if(T[u].r != NIL)setDepth(T[u].right, d+1);
      |          ^
main.c:50:10: error: 'Node' has no member named 'l'
   50 |   if(T[u].l != NIL)setDepth(T[u].left, d+1);
      |          ^
main.c: In function 'main':
main.c:60:12: error: expected ';' before 'T'
   60 | T[v].left=l
      |            ^
      |            ;
   61 | T[v].right=r
      | ~           
main.c:68:3: error: too many arguments to function 'setHeight'
   68 |   setHeight(root,0);
      |   ^~~~~~~~~
main.c:28:5: note: declared here
   28 | int setHeight(int u){
      |     ^~~~~~~~~
Language: C

#include<stdio.h>
  
#define MAX 10000
#define NIL -1
  
typedef struct{
  int parent,left,right;
}Node;
  
Node Ans[MAX];
int Depth[MAX],Height[MAX],n;
  
void calcDepth(int,int);
int calcHeight(int);
int getSibling(int);
void print(int);

void calcDepth(int u, int d){
  
  if(u == NIL)return;
  Depth[u] = d;
  calcDepth(Ans[u].left,d+1);
  calcDepth(Ans[u].right,d+1);
}
  
int calcHeight(int u){
  int h1,h2;
  
  h1 = h2 = 0;
  if(Ans[u].left != NIL)h1 = calcHeight(Ans[u].left) + 1;
  if(Ans[u].right != NIL)h2 = calcHeight(Ans[u].right) + 1;
  return Height[u] = (h1 > h2 ? h1 : h2); 
}
  
int getSibling(int u){
  
  if(Ans[u].parent == NIL)return NIL;

  if(Ans[Ans[u].parent].left != u && Ans[Ans[u].parent].left != NIL)
    return Ans[Ans[u].parent].left;

  if(Ans[Ans[u].parent].right != u && Ans[Ans[u].parent].right != NIL)
    return Ans[Ans[u].parent].right;

  return NIL;
}
  
void print(int u){
  int deg = 0;
  
  printf("node %d: parent = %d, sibling = %d, ",u,Ans[u].parent,getSibling(u));
  
  deg = 0;
  
  if(Ans[u].left != NIL)deg++;
  if(Ans[u].right != NIL)deg++;
  
  printf("degree = %d, depth = %d, height = %d, ",deg,Depth[u],Height[u]);
  
  if(Ans[u].parent == NIL)printf("root\n");
  else if(Ans[u].left == NIL && Ans[u].right == NIL)printf("leaf\n");
  else printf("internal node\n");
}

int main(){
  int i,node,left,right,root = 0;
  
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    Ans[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&node,&left,&right);
    Ans[node].left = l;
    Ans[node].right = r;
    if(left != NIL)Ans[left].parent = node;
    if(right != NIL)Ans[right].parent = node;
  }
  
  for(i=0;i<n;i++){
    if(Ans[i].parent == NIL)root = i;
  }
   
  calcDepth(root,0);
  calcHeight(root);
  
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:75:22: error: 'l' undeclared (first use in this function)
   75 |     Ans[node].left = l;
      |                      ^
main.c:75:22: note: each undeclared identifier is reported only once for each function it appears in
main.c:76:23: error: 'r' undeclared (first use in this function)
   76 |     Ans[node].right = r;
      |                       ^
Language: C


#include<stdio.h>

typedef struct{
  int p,l,r,s;
}Node;

int depth(Node*,int,int);
int height(Node*,int,int);

int main(){
  int num,i,j,k,number;
  Node node[N]; 
  
  scanf("%d",&num);

  for(i=0; i<num; i++){
 node[i].p = -1;
  }  
  for(i=0; i<num; i++){
    scanf("%d",&number);
    scanf("%d",&node[number].l);
    scanf("%d",&node[number].r);
    node[node[number].l].p = number;
    node[node[number].r].p = number;
  }
  
  
  for(i=0; i<num; i++){
    printf("node %d: parent = %d, ",i,node[i].p);

    if(node[i].p == -1)printf("sibling = -1, ");
    else if(node[node[i].p].l == i) printf("sibling = %d, ",node[node[i].p].r);
    else  printf("sibling = %d, ",node[node[i].p].l);

    if(node[i].l == -1) printf("degree = 0, ");
    else printf("degree = 2, ");

    printf("depth = %d, height = %d, ",depth(node,i,0),height(node,i,0));
    
    if(node[i].p==-1) printf("root\n");
    else if(node[i].l==-1) printf("leaf\n");
    else printf("internal node\n");
  }
  

  return 0;
}


int depth(Node *node,int num,int count){
  if(node[num].p==-1)return count;
  count++;
  count = depth(node,node[num].p,count);
  return count;
}



int height(Node *node,int num,int max){
  static int count;
  if(node[num].l == -1){
    if(max < count) max = count;
 
    return max;
  }
  count++;
  max = height(node,node[num].l,max);
  max = height(node,node[num].r,max);
  
  count--;
  return max;
}

Compiler output:
main.c: In function 'main':
main.c:13:13: error: 'N' undeclared (first use in this function)
   13 |   Node node[N];
      |             ^
main.c:13:13: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

#define N 10000
#define Nil -1

typedef struct{
  int p,l,r;
    }Node;

Node T[N];
int n,D[N],H[N];

void setDepth(int, int);
int setHeight(int);
int getSibling(int);
void print(int);

int main(){
  int i,v,l,r,root=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p = Nil;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);

    T[v].l = l;
    T[v].r = r;

    if(l!=Nil) T[l].p = v;
    if(r!=Nil) T[r].p = v;
  }

  for(i=0;i<n;i++)
    if(T[i].p == Nil) root = i;

  setDepth(root,0);
  setHeight(root);

  for(i=0;i<n;i++)
    print(i);

  return 0;
}

void setDepth(int u, int d){

  if(u==Nil) return;

  D[u] = d;

  setDepth(T[u].l, d+1);
  setDepth(T[u].r, d+1);

}

int setHeight(int u){
  int h1,h2;

  h1 = h2 = 0;

  if(T[u].l != Nil) h1 = setHeight(T[u].l) + 1;
  if(T[u].r != Nil) h2 = setHeight(T[u].r) + 1;

  return H[u] = (h1 > h2 ? h1 : h2); 
}

int getSibling(int u){

  if(T[u].p ==Nil) return Nil;

  if(T[T[u].p].l != u && T[T[u].p].l != Nil)
    return T[T[u].p].l;  
  if(T[T[u].p].r != u && T[T[u].p].r != Nil)
    return T[T[u].p].r;

  return Nil;
}

void print(int u){
  int deg;
 
  printf("node %d: parent = %d, sibling = %d, ",u,T[u].p,getSibling(u));
 
  deg = 0;
 
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
 
  printf("degree = %d, depth = %d, height = %d, ",deg,D[u],H[u]);
 
  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}

Compiler output:
main.c: In function 'print':
main.c:88:16: error: 'NIL' undeclared (first use in this function); did you mean 'Nil'?
   88 |   if(T[u].l != NIL)deg++;
      |                ^~~
      |                Nil
main.c:88:16: note: each undeclared identifier is reported only once for each function it appears in
Language: C

include<stdio.h>
#define NIL -1
#define N 100005
 struct Node{
   int p,l,r;
 };

   struct Node T[N];

int depth(int);
int sibling(int);
int degree(int);
int height(int);

int main(){
  int id,left,right;
  int i,j;
  int n;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }

  for(i=0; i < n; i++){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",\
i,T[i].p,sibling(i),degree(i),depth(i),height(i));

if(T[i].p==NIL){
      printf("root\n");
    }

    else if(T[i].l==NIL){
      printf("leaf\n");
    }

    else{
      printf("internal node\n");
    }

  }

  return 0;
}
nt sibling(int u){
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL) return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL) return T[T[u].p].r;
  return NIL;
}

int degree(int u){
  if(T[u].l==NIL && T[u].r==NIL) return 2;
  else if(T[u].l!=NIL && T[u].r!=NIL) return 0;
  else return 1;
}

int depth(int u){
  int d=0;
 while(T[u].p!=NIL){
    u=T[u].p;
    d++;
  }
  return d;
}

int height(int u){
  int d=0;
  while(T[u].l !=NIL || T[u].r !=NIL){
    if(T[u].l!=NIL){
      u=T[u].l;
      d++;
    }
    else if(T[u].r!=NIL){
   u=T[u].r;
      d++;
    }
  }
    return d;
}

Compiler output:
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    1 | include<stdio.h>
      |        ^
main.c:8:16: error: array type has incomplete element type 'struct Node'
    8 |    struct Node T[N];
      |                ^
main.c: In function 'main':
main.c:20:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   20 |   scanf("%d",&n);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | include<stdio.h>
main.c:20:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   20 |   scanf("%d",&n);
      |   ^~~~~
main.c:20:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:28:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   28 |   printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",\
      |   ^~~~~~
main.c:28:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:28:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:28:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c: At top level:
main.c:47:1: error: unknown type name 'nt'; did you mean 'int'?
   47 | nt sibling(int u){
      | ^~
      | int
Language: C

#include<stdio.h>
#define NIL -1
#define N 100005
 struct Node{
   int p,l,r;
 };

   struct Node T[N];

int depth(int);
int sibling(int);
int degree(int);
int height(int);

int main(){
  int id,left,right;
  int i,j;
  int n;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }

  for(i=0; i < n; i++){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",\
i,T[i].p,sibling(i),degree(i),depth(i),height(i));

if(T[i].p==NIL){
      printf("root\n");
    }

    else if(T[i].l==NIL){
      printf("leaf\n");
    }

    else{
      printf("internal node\n");
    }

  }

  return 0;
}
nt sibling(int u){
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL) return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL) return T[T[u].p].r;
  return NIL;
}

int degree(int u){
  if(T[u].l==NIL && T[u].r==NIL) return 2;
  else if(T[u].l!=NIL && T[u].r!=NIL) return 0;
  else return 1;
}

int depth(int u){
  int d=0;
 while(T[u].p!=NIL){
    u=T[u].p;
    d++;
  }
  return d;
}

int height(int u){
  int d=0;
  while(T[u].l !=NIL || T[u].r !=NIL){
    if(T[u].l!=NIL){
      u=T[u].l;
      d++;
    }
    else if(T[u].r!=NIL){
   u=T[u].r;
      d++;
    }
  }
    return d;
}

Compiler output:
main.c:47:1: error: unknown type name 'nt'; did you mean 'int'?
   47 | nt sibling(int u){
      | ^~
      | int
Language: C

#include<stdio.h>
#define NIL -1
#define N 100005
 struct Node{
   int p,l,r;
 };

   struct Node T[N];

int depth(int);
int sibling(int);
int degree(int);
int height(int);

int main(){
  int id,left,right;
  int i,j;
  int n;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    T[i].p=NIL;
    T[i].l=NIL;
    T[i].r=NIL;
  }

  for(i=0; i < n; i++){
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",
i,T[i].p,sibling(i),degree(i),depth(i),height(i));

if(T[i].p==NIL){
      printf("root\n");
    }

    else if(T[i].l==NIL){
      printf("leaf\n");
    }

    else{
      printf("internal node\n");
    }

  }

  return 0;
}
nt sibling(int u){
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL) return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL) return T[T[u].p].r;
  return NIL;
}

int degree(int u){
  if(T[u].l==NIL && T[u].r==NIL) return 2;
  else if(T[u].l!=NIL && T[u].r!=NIL) return 0;
  else return 1;
}

int depth(int u){
  int d=0;
 while(T[u].p!=NIL){
    u=T[u].p;
    d++;
  }
  return d;
}

int height(int u){
  int d=0;
  while(T[u].l !=NIL || T[u].r !=NIL){
    if(T[u].l!=NIL){
      u=T[u].l;
      d++;
    }
    else if(T[u].r!=NIL){
   u=T[u].r;
      d++;
    }
  }
    return d;
}

Compiler output:
main.c:47:1: error: unknown type name 'nt'; did you mean 'int'?
   47 | nt sibling(int u){
      | ^~
      | int
Language: C

#include<stdio.h>
 
#define MAX 100000
 
struct Node {
  int p,l,r;
};
 
struct Node T[MAX];
int D[MAX],H[MAX]; 

int Sibling(int);
void Depth(int,int);
int Height(int);
void print(int);

int main()
{
  int i,n,left,right,id,root = 0;
 
  scanf("%d",&n);
 
  for(i = 0; i < n ;i++){
    T[i].p = -1;
  }
 
  for(i = 0; i < n; i++){ 
    scanf("%d%d%d",&id,&left,&right);
 	T[id].l = left;
 	T[id].r = right;
 	if(left != -1) T[left].p = id;
 	if(right != -1) T[right].p = id;
  }
 
 for(i = 0; i < n; i++){
 	if(T[i] == -1) root = i;
 }
 
 Depth(root, 0);
 Height(root);
 
 for(i = 0; i < n; i++){
 	print(i);
 }
  
  return 0;
}
 
int Sibling(int i){
 	if(T[i].p == -1) return -1;
 	else if(T[T[i].p].l != i && T[T[i].p].l != -1) return T[T[i].p].l;
 	else if(T[T[i].p].r != i && T[T[i].p].r != -1) return T[T[i].p].r;
 	else return -1;
 }
 
void Depth(int root,int x){
	if(root == -1) return;
	D[root] = x;
	Depth(T[root].l,x+1);
	Depth(T[root].r,x+1);
}

int Height(int root){
	int h1 = 0;
	int h2 = 0;
	if(T[root].l != -1) h1 = Height(T[root].l) + 1;
	if(T[root].r != -1) h2 = Height(T[root].r) + 1;
	
	if(h1 > h2){
	H[root] = h1;
	return h1;
	}
	else {
	H[root] = h2;
	return h2;
	}
}

void print(int i){
	int count = 0;
	
	printf("node %d:, parent = %d, sibling - %d, ",i,T[i].p,Sibling(i));
	
	if(T[i].l != -1) count++;
	if(T[i].r != -1) count++;
	
	printf("degree = %d, depth = %d, height = %d, ",count,D[i],H[i]);
	
	if(T[i].p == -1) printf("root\n");
    else if(T[i].l == -1 && T[i].r == -1) printf("leaf\n");
    else printf("internal node\n[");
}

Compiler output:
main.c: In function 'main':
main.c:36:17: error: invalid operands to binary == (have 'struct Node' and 'int')
   36 |         if(T[i] == -1) root = i;
      |            ~~~~ ^~
      |             |
      |             struct Node
Language: C

#include<stdio.h>


#define MAX 1000
#define default -1
 
typedef struct node{
  int parent,left,right;
}Node;
 
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int, int);
int setHeight(int );
int getSibling(int );

int main(){
  int i,v,l,r,deg,root=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].parent =default;

  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != default)T[l].parent = v;
    if(r != default)T[r].parent = v;
  }
 
  for(i=0; i<n; i++){
    if(T[i].parent == default) root = i;
  }
  setDepth(root, 0);
  setHeight(root);
 
  for(i = 0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].parent);
    printf("sibling = %d, ", getSibling(i));
    deg = 0;
    if(T[i].left != default) deg++;
    if(T[i].right != default) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
 
    if(T[i].parent == default){
      printf("root\n");
    } else if(T[i].left == default && T[i].right == default){
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}
 
 
 
void setDepth(int u, int d){
  if(u==default) return;
  D[u]=d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}
 
int setHeight(int u) {
  int h1=0, h2=0;
  if(T[u].left != default)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != default)
    h2 = setHeight(T[u].right) + 1;

  if(h1>h2)return H[u]=h1;
  else return H[u]=h2;
}
 
int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

Compiler output:
main.c: In function 'getSibling':
main.c:83:21: error: 'NIL' undeclared (first use in this function)
   83 |   if(T[u].parent == NIL) return NIL;
      |                     ^~~
main.c:83:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>


#define MAX 1000
#define default -1
 
typedef struct node{
  int parent,left,right;
}Node;
 
Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int, int);
int setHeight(int );
int getSibling(int );

int main(){
  int i,v,l,r,deg,root=0;
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].parent =default;

  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l != default)T[l].parent = v;
    if(r != default)T[r].parent = v;
  }
 
  for(i=0; i<n; i++){
    if(T[i].parent == default) root = i;
  }
  setDepth(root, 0);
  setHeight(root);
 
  for(i = 0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].parent);
    printf("sibling = %d, ", getSibling(i));
    deg = 0;
    if(T[i].left != default) deg++;
    if(T[i].right != default) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", H[i]);
 
    if(T[i].parent == default){
      printf("root\n");
    } else if(T[i].left == default && T[i].right == default){
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }
  return 0;
}
 
 
 
void setDepth(int u, int d){
  if(u==default) return;
  D[u]=d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}
 
int setHeight(int u) {
  int h1=0, h2=0;
  if(T[u].left != default)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != default)
    h2 = setHeight(T[u].right) + 1;

  if(h1>h2)return H[u]=h1;
  else return H[u]=h2;
}
 
int getSibling(int u){
  if(T[u].parent == default) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != default)
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != default)
    return T[T[u].parent].right;
  return default;
}

Compiler output:
main.c: In function 'getSibling':
main.c:83:37: error: 'NIL' undeclared (first use in this function)
   83 |   if(T[u].parent == default) return NIL;
      |                                     ^~~
main.c:83:37: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define MAX 25
#define N 100000
#define NIL -1
struct Node {
  int parent;
  int left;
  int right;
};
struct Node T[MAX];
int D[MAX];
int H[MAX];

void getDepth(int x,int y){
  D[x]=y;
  if(T[x].right != NIL)
    getDepth(T[x].right,y);
  if(T[x].left != NIL)
    getDepth(T[x].left,y+1);
}

int getHeight(int x){
  int a=0,b=0;
  if(T[x].right!=NIL)
    a=getHeight(T[x].right)+1;
  if(T[x].left!=NIL)
    b=getHeight(T[x].left)+1;

  return H[x]=(a > b ? a : b);
}

int getSibling(int x){
  int y;
  y=T[x].parent;
  if(T[x].parent==NIL)
    return NIL;
  if(T[y].right != x && T[y].right != NIL)
    return T[y].right;
  if(T[y].left != x && T[y].left != NIL)
    return T[y].left;
  return NIL;
}
  


int main(){
  int a,n,i,j,x;
  int id,left,right,y,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;  
  }
    
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].left=left;
    T[id].right=right;
    if(left != NIL)
      T[left].parent=id;
    if(left != NIL)
      T[right].parent=id;
  }
  

Compiler output:
main.c: In function 'main':
main.c:63:3: error: expected declaration or statement at end of input
   63 |   }
      |   ^