Professional Documents
Culture Documents
h>
#include <stdlib.h>
struct node {
char item;
struct node* left;
struct node* right;
};
}
count++;
}
}
struct node* createNode(value) {
struct node* newNode = malloc(sizeof(struct node));
newNode->item = value;
newNode->left = NULL;
newNode->right = NULL;
return newNode;
}
int main() {
struct node* root = createNode(grammer[0][1]);
insertLeft(root, 'T');
insertRight(root, 'a' );
insertLeft(root->left, 'b');
insertRight(root->left, 'c');
printf("%d\n",maxDepth(root));
printf("Inorder traversal \n");
printf("First of S : ");
inorderTraversal(root,maxDepth(root),1);
printf("\nFirst of T : ");
inorderTraversal(root->left,maxDepth(root->left),1);
insertLeft(root->left, 'b');
insertRight(root->left, 'c');
printf("%d\n",maxDepth(root));
printf("Inorder traversal \n");
printf("First of S : ");
inorderTraversal(root,maxDepth(root),1);
printf("\nFirst of T : ");
inorderTraversal(root->left,maxDepth(root->left),1);