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

2 please Cs 209 Spring 2018 Quiz 7 Queue 1 Suppose q is a queue as shown below e

ID: 3706565 • Letter: 2

Question

2 please

Cs 209 Spring 2018 Quiz 7 Queue 1 Suppose q is a queue as shown below execution of the (pseudo) code Show the final queue after the front 3 11517 16 25116 1 30 while tq.po11 0430 g offer (g po110a polLO g.offer(q.poll02 2. Circular queue array implementation is used for QueueClass. Suppose that a QueueClass object of maximum size 40. Suppose the value of queueFront is 1 and the value of queueRear is 9. a) What is the queue size (number of elements actually in the queue)? b) If fifteen at the front are removed from this queue, what is the value of queueFront and the value of queueRear? c) Three String objects "Red", "Green", "Blue" are added in sequence. Which slots of the array (partially shown below) will them be at, respectively? 6]7] 101 1] 12] 13] d) What are the values of queueFront and the value of queueRear after adding these three in the queue in part c)? e the code to initialize the following objects PriorityQueue object, card_pql, of Card types (with the natural order) - new PRORity Queue PriorityQueue object, card_pq2, of Card types (with the BySuitFirst arator) of maximum size 208

Explanation / Answer

Solution:

a)

The size of the queue is

queueRear-queueFront+1 = 31-9+1 = 23

b)

then the queueFront will remain 31 and queueRear will become 8

c)

[6]= "Red"

[7]= "Green"

[8]= "Blue"

d)

queueFront= 6

queueRear= 8

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

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