Language: C++

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

typedef struct node{
  int parent;
  int left;
  int parent;
}node;

int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
void printTree(void);

node *tree;

int a;

int main(){
  
  int id,left,right,i;
  
  scanf("%d",&a);
  tree = (node *)malloc(sizeof(node)*a);
  for(i=0;i<a;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<a;i++){
    scanf("%d %d %d",&id,&left,&right);
    
    tree[id].left = left;
    
    tree[id].right = right;
    
    tree[tree[id].left].parent = id;
    
    tree[tree[id].right].parent = id;
  }

  printTree();

  return 0;
}

int getSibling(int c){
  
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    
    right = tree[tree[c].parent].right;

    if(left!=-1&&c!=left) return left;
    
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}

int getDegree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
 
  return d;
}

int getDepth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}

int getHeight(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return getHeight(tree[c].right)+1;
  if(tree[c].right==-1) return getHeight(tree[c].left)+1;
  if(getHeight(tree[c].left)<getHeight(tree[c].right))
    return getHeight(tree[c].right)+1;
  else return getHeight(tree[c].left)+1;
  return d;
}

void printTree(){
  int i,dep,h;
  for(i=0;i<a;i++){
    dep=getDepth(i);
    h=getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,getSibling(i),getDegree(i),dep,h);
    if(dep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }

  return;
}

Compiler output:
a.cc:8:7: error: redeclaration of 'int node::parent'
    8 |   int parent;
      |       ^~~~~~
a.cc:6:7: note: previous declaration 'int node::parent'
    6 |   int parent;
      |       ^~~~~~
a.cc: In function 'int main()':
a.cc:35:14: error: 'node' {aka 'struct node'} has no member named 'right'
   35 |     tree[id].right = right;
      |              ^~~~~
a.cc:39:19: error: 'node' {aka 'struct node'} has no member named 'right'
   39 |     tree[tree[id].right].parent = id;
      |                   ^~~~~
a.cc: In function 'int getSibling(int)':
a.cc:53:34: error: 'node' {aka 'struct node'} has no member named 'right'
   53 |     right = tree[tree[c].parent].right;
      |                                  ^~~~~
a.cc: In function 'int getDegree(int)':
a.cc:65:14: error: 'node' {aka 'struct node'} has no member named 'right'
   65 |   if(tree[c].right!=-1) d++;
      |              ^~~~~
a.cc: In function 'int getHeight(int)':
a.cc:81:32: error: 'node' {aka 'struct node'} has no member named 'right'
   81 |   if(tree[c].left==-1&&tree[c].right==-1) return 0;
      |                                ^~~~~
a.cc:82:49: error: 'node' {aka 'struct node'} has no member named 'right'
   82 |   if(tree[c].left==-1) return getHeight(tree[c].right)+1;
      |                                                 ^~~~~
a.cc:83:14: error: 'node' {aka 'struct node'} has no member named 'right'
   83 |   if(tree[c].right==-1) return getHeight(tree[c].left)+1;
      |              ^~~~~
a.cc:84:48: error: 'node' {aka 'struct node'} has no member named 'right'
   84 |   if(getHeight(tree[c].left)<getHeight(tree[c].right))
      |                                                ^~~~~
a.cc:85:30: error: 'node' {aka 'struct node'} has no member named 'right'
   85 |     return getHeight(tree[c].right)+1;
      |                              ^~~~~