Computer Science > STUDY GUIDE > California State University, Long Beach - CS 311pqueue.cpp (All)

California State University, Long Beach - CS 311pqueue.cpp

Document Content and Description Below

// CS311 Yoshii - HW5 Priority Queue Implementation File // Complete all ** parts and give good comments // ** Do not delete my comments. // ================================================= // HW... 5 Priority Printer Queue // YOUR NAME: KANISHQ PATEL // File Type: implementation pqueue.cpp // ================================================= #include "pqueue.h" // constructor pqueue::pqueue() { count = 0; // no jobs yet } // destructor does nothing pqueue::~pqueue() {} // Purpose: to add a job to a right place in the Pqueue // Argument: j is the job priority number // Remember that the current last job is in slot count-1. void pqueue::insertjob(int j) { cout << "Adding: " << j << endl; if(count < MAX){// ** add the job j at the rear (and update count) Q[count]=j; count++;} else {// ** if possible else display error message. cout<< "..Cannot add..Full!" << endl; } trickleup(); // moves the job to the right place } // Purpose: to print a job and reheapify the Pqueue void pqueue::printjob() { cout << "Printing: " << Q[0] <<endl; reheapify(); } // Purpose: to display all jobs void pqueue::displayAll() { cout << "Jobs: " ; for(int i=0; i<count; i++){// ** loop to display jobs from slot 0 to slot count-1 horizontally. No need to show a tree format. cout<< Q[i]<< " ";} cout << endl; } // Utility functions follow: ------------------ void pqueue::swap(int loc1, int loc2) { // ** swap the values in these locations in Q int temp = Q[loc1]; Q[loc1]=Q[loc2]; Q[loc2]= temp; } // Purpose: to make the very last job trickle up to the right location. Never do X--. [Show More]

Last updated: 1 year ago

Preview 1 out of 3 pages

Reviews( 0 )

$3.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

GET ASSIGNMENT HELP
26
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 10, 2021

Number of pages

3

Written in

Seller


seller-icon
Muchiri

Member since 3 years

208 Documents Sold


Additional information

This document has been written for:

Uploaded

Apr 10, 2021

Downloads

 0

Views

 26

Document Keyword Tags

Recommended For You

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·