Write a program that is capable of creating a binary tree starting fromthe root node using structures and dynamic memory allocation. Ensurethat the tree constructed is binary. Once the user creates the binary tree
at run-time, your program should also check if the binary tree is a binary-search tree or not. If not, it should output the node at the minimum depth
from the root which violates the condition for a binary search tree.Input: The code initially asks for the root node and then dynamicallycreates a binary tree with non-negative integer values until the user isdone.Output: The output should be a single string displaying ‘YES’ or ‘NO’accordingly if the tree entered is binary search tree or not. If not, it should
1
display: x node at i depth violates the BST conditionExample: One way to do is to ask for the root node to begin with, thenkeep asking for a left/right child; followed by a prompt which shows acurrent root value and asks for its subsequent children and so on. Twospecial characters, say ! and * can be used to denote that the user isnot interested in child node values for the current node and end of thetree respectively. In this way, you create the binary tree, after which youshould code to check if it is a binary search tree or not and display theoutput.(You are free to implement in any way you please). Write using c Progamming Language.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here