Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5 parts: main.cpp/ heap.h/Hea.cpp/ Printjob.h/ Printjob.cpp Implement a max-heap to manage print jobs. You are given the PrintJob class Class PrintJob PrintJob.h #ifndef #de fine
5 parts: main.cpp/ heap.h/Hea.cpp/ Printjob.h/ Printjob.cpp
Implement a max-heap to manage print jobs. You are given the PrintJob class Class PrintJob PrintJob.h #ifndef #de fine PRINT-JOB H PRINTJOBH using namespace std; class PrintJob private: int priority; int jobNumber; int numPages public: PrintJob int, int, int) int getPriority int getJobNumber int getPages //You can add additional functions here #endif PrintJob.cpp #include "PrintJob "h" PrintJob::PrintJob ( nt setP, int setJ, int numP ) :priority (setP), jobNumber(setJ), numPages (numP) int PrintJob::getPriority return priority; int PrintJob::getJobNumber return jobNumber; int PrintJob: : getPages return numPages; class Heap #ifndef HEAPH #de fine HEAPH #include "PrintJob . h" const int MAXHEAPSIZE = 10; - - class Heap f private: PrintJob* arr [MAX HEAP SIZE) int numItems //current number of items in heap // Notice this is an array of PrintJob pointers public: Initializes an empty heap. Heap) /Inserts a PrintJob to the heap without violating max-heap properties.* void enqueue PrintJob*) *Removes the node with highest priority from the heap. Follow the algorithm on priority-queue slides. void dequeue *Returns the node with highest priority*/ PrintJob highest *Prints the PrintJob with highest priority in the following format: Priority: priority, Job Number jobNum, Number of Pages: numPages (Add a new line at the end.)*/ void print ) private: /This function is called by dequeue function to move the new root down the heap to the appropriare location.*/ void trickleDown (int); //You can include additional private helper functions here #endif main.cpp Use the following main function to test your program: #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started