Question: write the complete program given the following Description: This project's objective is to implement a novel templated queue data structure called NovelQueue in C +

write the complete program given the following Description: This project's objective is to implement a novel templated queue data structure called NovelQueue in C++. This queue will simulate a CPU scheduling system, managing a collection of CPU jobs and their execution characteristics. In real-world computing environments, operating systems use CPU scheduling algorithms to determine the order in which jobs (processes) are executed. This project simulates this concept by allowing students to manipulate a queue of CPU jobs with various attributes, including priority, job type, CPU time consumed, and memory consumption. By doing so, students will gain a practical understanding of how efficient CPU scheduling is critical for optimizing system performance and managing system resources.Your Project Implementation: As part of this project, three classes are CPUJob Class, Queue class (linked list), and the NovelQueue. Here, I will give the required fields for each of the classes. You have the freedom to add more fields and methods.class CPUJob { public: int job_id; // Unique identifier for the job int priority; // Priority level of the job (1-10) int job_type; // Job type (1-10) int cpu_time_consumed; // Total CPU time consumed by the job int memory_consumed; // Total memory consumed thus far }; template class Queue { public: DT* JobPointer; // Pointer to a job (e.g., CPUJob) Queue Data Structure Operations
Implement the following operations for NovelQueue:
1. Add (Enqueue)-'A':
- Format: A job_id priority job_type cpu_time_consumed memory_consumed
- Description: Adds a new job to the queue. After insertion, update the sorted array of pointers to ensure it reflects the new job's position based on its job ID.
2. Remove (Dequeue)-'R':
- Format: R
- Description: Removes the job at the front of the queue. Update the sorted array to reflect the removal and maintain its sorted order.
3. Modify -'M':
- Format: M job_id new_priority new_job_type new_cpu_time_consumed new_memory_consumed
- Description: Searches for the job with the specified job_id, dequeues it, modifies its attributes as specified, and enqueues it back.
4. Change Job Values -'C':
- Format: C job_id field_index new_value
- Description: Changes a specific field of the job with the given job_id. The field_index corresponds to different fields such as priority, job type, CPU time consumed, or memory consumed.
5. Promote:
- Format: P job_id positions
- Description: Promotes the job with job_id towards the front by the specified number of positions. If the number exceeds its current position, move it to the front.
6. Reorder Based on Attributes -'O':
- Format: O attribute_index
- Description: Reorders the queue based on the specified attribute (e.g., CPU time consumed, priority). This operation returns a new instance of the reordered NovelQueue.
7. Display-'D':
- Format: D
- Description: Displays all elements of the queue, including all fields of the job record.
8. Count-'N':
- Format: N
- Description: Returns the number of elements in the queue.
9. List Jobs -'L':
- Format: L
- Description: Iterates through the array of pointers in NovelQueue (sorted by job IDs) and prints each job's information using the CPUJob display method. Also, shows the position of each job in the queue.
Data Structure Constraints
1. pointers must always be sorted based on job IDs whenever jobs are added, removed, or modified.
2. Operations like promotion and job attribute changes should utilize the sorted array to enhance efficiency. Use binary search on the sorted array to search jobs and ensure optimal performance.
3. Thoroughly test all the operations to ensure the correct functionality of the NovelQueue.
Your Project Implementation: As part of this project, three classes are CPUJob Class, Queue class (linked list), and the NovelQueue. Here, I will give the required fields for each of the classes. You have the freedom to add more fields and methods.
```
class CPUJob {
public:
int job_id; // Unique identifier for the job
int priority; // Priority level of the job (1-10)
int job_type; // Job type (1-10)
int cpu_time_consumed; // Total CPU time consumed by the job
int memory_consumed; // Total memory consumed thus far
};
``` Sample Input
50
A 101521502000
A 102311001024
A 103742504096
A 104233002048
A 10565200512
A 106421753072
A 107834001024
A 10815502048
A 109512258192
A 1109450016384
M 105852201024
C 10219
P 1082
R
O 1
D
A 111723501024
A 112341804096
C1113450
L
N
M 103642755120
A 11323100256
P 1075
C 10827
O 4
D
A 114411252048
R
L
N
P 1101
P 1093
P 1042
O 2
D
A 115253002048
A 116521751024
P 1154
O 3
D
C 11517
A 11733200512
P 1162
O 4
L
R
P 1121
A 118644003072
O 1
D
N
write the complete program given the following

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 Programming Questions!