Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

58. Is it true that ? Explain.

Answered: 1 week ago