Question
This program performs basic operations on a binary search tree. It reads a sequence of instructions from the standard input stream and outputs the results
This program performs basic operations on a binary search tree. It reads a sequence of instructions from the standard input stream and outputs the results to the standard output stream.
The program accepts the following instructions:
- add value add the value to the tree
- min remove and return the smallest value stored in the current tree (should have no effect if the current tree is empty)
- max remove and return the largest value stored in the current tree (should have no effect if the current tree is empty)
- print print the values stored in the current tree in order of the inorder traversal; the values should be separated by a single space
The main function in problem2.c reads and parses the input stream and calls appropriate functions to perform the instructions. Your task is to implement those functions so that the output produced by the program is correct.
Example
Input:
add park add snow add zoo add car add dinner print min max print add crab add rank add herb add rabbit add sand print max min print min min max max print max min print min print
Output:
car dinner park snow zoo dinner park snow crab dinner herb park rabbit rank sand snow dinner herb park rabbit rank sand park rabbit
(notice that the last two lines of the output are blanks since the tree is empty at that point!).
Please use C to solve this
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started