Problem

The board of education maintains a database of substitute teachers in the area. If a tempo...

The board of education maintains a database of substitute teachers in the area. If a temporary replacement is necessary for a certain subject, an available teacher is sent to the school that requests him or her. Write a menu-driven program maintaining this database.

The file substitutes lists the first and last names of the substitute teachers, an indication of whether or not they are currently available (Y(es) or N(o)), and a list of numbers that represents the subjects they can teach. An example of substitutes is:

Hilliard Roy

Y 0 4 5

Ennis John

N 2 3

Nelson William

Y 1 2 4 5

Baird Lyle

Y 1 3 4 5

Geiger Melissa

N 3 5

Kessel Warren

Y 3 4 5

Scherer Vincent

Y 4 5

Hester Gary

N 0 1 2 4

Linke Jerome

Y 0 1

Thornton Richard

N 2 3 5

Create a class teacher with three data members: index, left child, and right child. Declare an array subjects with the same number of cells as the number of subjects, each cell storing a pointer to class Teacher, which is really a pointer to the root of a binary search tree of teachers teaching a given subject. Also, declare an array names with each cell holding one entry from the file.

First, prepare the array names to create binary search trees. To do that, load all entries from substitutes to names and sort names using one of the algorithms discussed in this chapter. Afterward, create a binary tree using the function balance() from Section: go through the array names, and for each subject associated with each name, create a node in the tree corresponding to this subject. The index field of such a node indicates a location in names of a teacher teaching this subject. (Note that insert() in balance() should be able to go to a proper tree.) Figure 1 shows the ordered array names and trees accessible from subjects as created by balance() for our sample file.

Allow the user to reserve teachers if so requested. If the program is finished and an exit option is chosen, load all entries from names back to substitutes, this time with updated availability information.

Figure Data structures used by the board of education for substitute teachers.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 9
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT