Question: Using C, help me with this hwk! The document is below!! CAUTION! I want the program to print words not integers which is different from
Using C, help me with this hwk!
The document is below!!
CAUTION! I want the program to print words not integers which is different from the instruction below. You may change few function names and things like typedef struct Integers_ to typedef struct Words_. Please help me!
Assignment
Use the following structure definition:
typedef struct Integers_
{
int num;
struct Integer_* leftPtr;
struct Integer_* rightPtr;
} Integer;
You will make a simple binary search tree using an input file. This tree will have pointers pointing both ways so that we can traverse the tree if we need to. Print out the tree in indorder fashion. Search the tree for a value to see if it exists.
Make sure and take advantage of the recursive functions we discussed in class and coded examples I provided!
Use the following function prototypes:
Integer* addNode(Integer*, int value);
Adds an integer to the stack. Returns the new top of the stack.
void printInOrder(Integer*);
Prints out all numbers, starting with the BOTTOM of the stack. Be careful! The pointer passed is pointing to the top of the stack.
void searchTree(Integer*, int value);
Frees all nodes in the tree. Be careful!!! Sample Output
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>1
Insert your Number: 10
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>1
Insert your Number: 11
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>1
Insert your Number: 12
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>3
10->11->12
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>2
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>3
10->11
Select an option:
1: add a number
2: take a number off
3: print numbers
4: quit
Option:
>4
RUN SUCCESSFUL (total time: 15s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
