Question: Implement the functions in the first image so that when they are run in the main for the second image, they produce an output like

 Implement the functions in the first image so that when theyare run in the main for the second image, they produce anoutput like the one above. This is a C problem. If you

Implement the functions in the first image so that when they are run in the main for the second image, they produce an output like the one above. This is a C problem. If you can provide comments that detail what you are doing, I would appreciate it.

#include #include #include #include "bst.h" void add ( bst_node ** root, char * word ) { void inorder ( bst_node * root ) { char * removeSmallest (bst_node ** root ) { return NULL; char * removeLargest (bst_node ** root ) { return NULL; #include #include #include #include "bst.h" int main() { bst_node * root = NULL; char * instruction = (char*) malloc (256*sizeof( char) ) ; char * word = NULL; while ( scanf("%s", instruction) > 0) { //printf ( "read: %c ", instruction); if ( strncmp(instruction, "add", 4) == 0 ) { //add a value to the tree word = (char*) malloc (256 * sizeof(char) ); scanf("%s ", word); add (&root, word); else if ( strncmp(instruction,"min", 4) == 0 ) { //remove the smallest value in the tree word = removeSmallest( &root); //free memory that was allocated for the word if (word != NULL) { free (word); word = NULL; } else if ( strncmp(instruction, "max", 4) == 0 ) { //remove the largest value in the tree word = removeLargest( &root); //free memory that was allocated for the word if (word != NULL) { free (word); word = NULL; else if ( strncmp(instruction,"print", 6) == 0){ //print the content of the tree in the inorder traversal inorder (root); printf (" "); else { printf ("Error: %s is not a valid instruction ", instruction); if (word != NULL) { free (word); word = NULL; if (instruction != NULL) { free (instruction); instruction = NULL; return 0; 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!