Starting from:

$25

Index Referencing implementation of binary tree Solved

Complete the implementation of the Index Referencing implementation of binary tree. (C language)

#include<stdio.h
/* 1 - Define symbolic constants MAX to represent the number of nodes in the tree*/


/* 2 - Define the structure of node where data represents either the operator or the operand in the node and the

children are represented as integer */

/* 3 - Declare an array of nodes and initialise the values based on the Index Referencing table. Where there is

supposed to be a NULL - because it is a leaf and not an operand, use -1 instead of 0 because 0 is the first
array index */


void displayNode(char data);

void preorder(int i);
void postorder(int i);
void inorder(int i);
main()
{
   printf("\nPre Order Traversal : ");
   preorder(0);
   printf("\nInOrder Traversal : ");
   inorder(0);
   printf("\nPost Order Traversal : ");
   postorder(0);
}

void displayNode(char data)
{
   printf("%c", data);
}

/*4 - Complete the function definition for the preorder function */
void preorder(int i)
{
   if (i != -1)
   {

   }
}

/*5 - Complete the function definition for the postorder function */
void postorder(int i)
{
   if (i != -1)
   {  
      
   }
}
/*6 - Complete the function definition for the inorder function */
void inorder(int i)
{
   if (i != -1)
   {
      
      
   }
}
 

More products