C Language is used:
/*A binary tree node*/ struct Tree{ int data; Tree *left, *right; }; /*Function prototypes*/ void stars(int i); void inorderTraversal(Tree *root); /*Function to print i number of starts followed by a new line*/ void stars(int i){ for(int j = 0; j < i; j++) printf("*"); printf("\n"); } /*Function to perform in-order traversal of a binary tree rooted at node root*/ void inorderTraversal(Tree *root){ if(root != NULL){ inorderTraversal(root->left);//Traverse left subtree first stars(root->data);//Print stars equivalent to value of data of current node inorderTraversal(root->right);//Traverse right subtree } }
NOTE:- If you need any help then let me know in the comments
Get Answers For Free
Most questions answered within 1 hours.