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: 3 years ago

Preview 1 out of 3 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of California State University, Long Beach - CS 311pqueue.cpp document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$3.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

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

51
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 10, 2021

Number of pages

3

Written in

All

Seller


Profile illustration for Muchiri
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Apr 10, 2021

Downloads

 0

Views

 51

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$3.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

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 © Scholarfriends · High quality services·