Question: This is done in C 1.4 bst: Binary search trees Write a program bst that manipulates binary search trees. It will receive commands from standard
1.4 bst: Binary search trees Write a program bst that manipulates binary search trees. It will receive commands from standard input, and print resposes to those commands to standard output A binary search tree is a binary tree that stores integer values in its interior nodes. The value for a particular node is greater than every value stored its left sub-tree and less than every value stored in its right sub-tree, The tree will no contain any value more than once, bst will eed to allocate space for new nodes as they are created using malloc; any allocated space should be deallocated using free before bst rminates This portion of the assignment has two parts. Part 1 In this part, you wil implement bst with three commands: insert n Adds a value to the tree, if not already present. The new node will always be added as the child of an existing node, or as the root. No existing node will change or move as as result of inserting an item. If n is already present in the tree, bst will print duplicate. Otherwise it will print inserted. The instruction format is an i followed by a decimal integer n search n Searches the tree for a value n. If n is presnt, bst will print present. Otherwise, it will print absent. The instruction format is an s followed by a space and an integer n print Prints the current tree structure, using the format in section 1.4.1 Part 2 In this part,you will implement bat with an additional fourth command delete n Removes a value from the tree. See section 1.4.2 for further discussion of deleting nodes If n is not present, print absent. Otherwise, print deleted. The instruction format is a d followed by a space and an integer n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
