Topic 1 : Suppose that the job entering the computer system (job) Given an assignment number (job number) And one from 0~9 Priority in (priority),0 Indicates the maximum priority ,9 Indicates the minimum priority . The job number of the job waiting to be executed by the job is saved in a priority queue (priority queue) in . Write a program , Use priority queues to store jobs , And allow the user to select the menu operation :R( Delete remove)、A( increase add) and L( list list). about R, Read the job number with the highest priority and delete it from the priority queue , If there are multiple jobs with the highest priority , Then delete the job with small job number from the priority queue ; about A, Read in the job number and priority , Then add it to the priority queue according to the above rules ; about L, Then all job numbers and their priorities in the queue are listed . The job number can be expressed as an integer , It can be given by the system when the job enters the system .
Design appropriate data element types , Use the unordered order table to realize the priority queue and write the verification code to verify each operation , Complete the demonstration scheme of job scheduling of the above computer system . Insert the new job at the end of the table . It is assumed that the job number can reflect the order in which jobs are added , Therefore, together with the job priority, a job can be uniquely identified .
Complete the problem with binary sort tree 1.