subject

In this assignment you will modify the program written in the previous assignment (bribe program) to use a binary search tree.

the application will look the same to the user as the application you created for assignment #4, and have the same sample output, with one exception. in assignment #4, if if the user entered a bribe amount that someone already in the list paid, then you "broke the tie" by "first come, first served." however, binary search trees cannot contain duplicate values. therefore, in this assignment, if the user enters a bribe amount that someone already in the list paid, then you will not add a new person to the list. instead, you just will advise the user that this bribe amount has already been paid, after which the application continues by displaying the menu to add, view or exit.

you will be creating a multi-file project with the following three files:

file name purpose
tree. h header file for ctree class
tree. cpp implementation file for ctree class
test. cpp driver file
as with assignment #4, you have been given all the code except for the implementation of the ctree class. the code for the driver file is given below. the accompanying module gives you all the member variables and functions of the ctree class and the member variables and constructor of the personrec structure, so writing the tree. h file should be a no-brainer. your task is to implement, in tree. cpp, the ctree member functions. there also is a powerpoint presentation on recursion that you can download.

note: as with assignment #4, you do not need to do any error checking to determine if the user typed in a legal menu choice (1, 2 or 3), a name, or a positive whole number for a bribe.

same rules as before for turning in your assignment, late assignments, doing your own work, etc.

code for test. cpp file

// test. cpp

#include

using namespace std;
#include
#include "tree. h"

int displaymenu (void);
void processchoice(int, ctree& );

int main (void)
{
int num;

ctree ct;
do
{
num = displaymenu();
if (num ! = 3)
processchoice(num, ct);
} while (num ! = 3);

return 0;
}

int displaymenu (void)
{
int choice;
cout < < "\nmenu\n";
cout < < "\n\n";
cout < < "1. add student to waiting list\n";
cout < < "2. view waiting list\n";
cout < < "3. exit program\n\n";
cout < < " enter choice: ";
cin > > choice;
return choice;
}

void processchoice(int choice, ctree& mytree)
{
switch (choice)
{
case 1: mytree. add (); break;
case 2: mytree. view (); break;
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:20
[a] create a class called “cycle” which has two instance integer variables as properties, “numberofwheels” and “weight.” create a constructor with two parameters, using the same variable names in the parameter list. assign each variable to numberofwheels” and “weight” respectively. write a separate application to test the class and display its properties. note: do not change the names of the instance variables or the variables listed in the constructor’s parameter list. [b] edit your class cycle by adding a default constructor which will assign the default values of 100 to represent the numberofwheels, and 1000 to represent the weight, by invoking a call to the other constructor. modify your application created in [a] to test the class.
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Which is the highest level of the hierarchy of needs model? a. humanity b. intrapersonal c. team d. interpersonal
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
The option enables you to modify a slide element in most presentation applications.
Answers: 2
question
Computers and Technology, 23.06.2019 20:30
If an appliance consumes 500 w of power and is left on for 5 hours, how much energy is used over this time period? a. 2.5 kwh b. 25 kwh c. 250 kwh d. 2500 kwh
Answers: 1
You know the right answer?
In this assignment you will modify the program written in the previous assignment (bribe program) to...
Questions
question
English, 12.12.2020 16:20
question
English, 12.12.2020 16:20
question
Health, 12.12.2020 16:20
question
English, 12.12.2020 16:20