Language: C

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

struct Node{
  int parent;
  int left;
  int right;
};
struct Node A[MAX];
int n,B[MAX],C[MAX];

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

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



Compiler output:
main.c: In function 'getSibling':
main.c:15:6: error: 'T' undeclared (first use in this function)
   15 |   if(T[s].parent==NIL)return NIL;
      |      ^
main.c:15:6: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:27: error: 'u' undeclared (first use in this function)
   16 |   if(T[T[s].parent].left!=u&&T[T[s].parent].left!=NIL)return T[T[s].parent].left;
      |                           ^
main.c: In function 'setHeight':
main.c:23:6: error: 'T' undeclared (first use in this function)
   23 |   if(T[x].left!=NIL) h1=setHeight(T[x].left)+1;
      |      ^
main.c:25:10: error: 'H' undeclared (first use in this function)
   25 |   return H[x]=(h1>h2?h1:h2);
      |          ^
main.c: In function 'setDepth':
main.c:30:6: error: 'u' undeclared (first use in this function)
   30 |   if(u==NIL)return;
      |      ^
main.c:31:3: error: 'D' undeclared (first use in this function)
   31 |   D[x]=y;
      |   ^
main.c:32:12: error: 'T' undeclared (first use in this function)
   32 |   setDepth(T[x].left,y+1);
      |            ^
main.c: In function 'print':
main.c:39:26: error: 'T' undeclared (first use in this function)
   39 |   printf("parent = %d, ",T[x].parent);
      |                          ^
main.c:47:25: error: 'D' undeclared (first use in this function)
   47 |   printf("depth = %d, ",D[x]);
      |                         ^
main.c:48:26: error: 'H' undeclared (first use in this function)
   48 |   printf("height = %d, ",H[x]);
      |                          ^
main.c: In function 'main':
main.c:61:5: error: 'T' undeclared (first use in this function)
   61 |     T[i].parent=NIL;
      |     ^
main.c:69:17: error: 'r' undeclared (first use in this function)
   69 |      T[x].right=r;
      |                 ^