Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Printer queue ========= 1. Add job 2. Print job 3. View jobs 4. Exit Enter choic

ID: 3562238 • Letter: P

Question

Printer queue
=========
1. Add job
2. Print job
3. View jobs
4. Exit
Enter choice: 3

No print jobs in queue.

[menu output]
Enter choice: 2

No print jobs in queue.

[menu output]
Enter choice: 1

Instructor (I or i), TA (T or t), or Student (S or s)? s

[menu output]
Enter choice: 3

job #1: Student

[menu output]
Enter choice: 1

Instructor (I or i), TA (T or t), or Student (S or s)? i

[menu output]
Enter choice: 3

job #2: Instructor
job #1: Student

[menu output]
Enter choice: 1

Instructor (I or i), TA (T or t), or Student (S or s)? t

[menu output]
Enter choice: 3

job #2: Instructor
job #3: TA
job #1: Student

[menu output]
Enter choice: 1

Instructor (I or i), TA (T or t), or Student (S or s)? i

[menu output]
Enter choice: 3

job #2: Instructor
job #4: Instructor
job #3: TA
job #1: Student

[menu output]
Enter choice: 2

Now printing job #2: Instructor

[menu output]
Enter choice: 3

job #4: Instructor
job #3: TA
job #1: Student

Explanation / Answer

#ifndef MAX_PRIORITYQ_H #define MAX_PRIORITYQ_H #include #include #include "print.h" #include "random.h" int parent(int i) { return (i - 1) / 2; } int left(int i) { if(i == 0) return 1; else return 2*i; } int right(int i) { if(i == 0) return 2; else return 2*i + 1; } void max_heapify(std::deque &A, int i, int heapsize) { int largest; int l = left(i); int r = right(i); if(l A[i]) largest = l; else largest = i; if(r A[largest]) largest = r; if(largest != i) { exchange(A, i, largest); max_heapify(A, largest, heapsize); //int j = max_heapify(A, largest, heapsize); //return j; } //return i; } void build_max_heap(std::deque &A) { int heapsize = A.size() - 1; for(int i = (A.size() - 1) / 2; i >= 0; i--) max_heapify(A, i, heapsize); } int heap_maximum(std::deque &A) { return A[0]; } int heap_extract_max(std::deque &A, int heapsize) { if(heapsize < 0) throw std::out_of_range("heap underflow"); int max = A.front(); //std::cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote