Don\'t fully grasp this: Assume you have a newly instantiated ArrayQueue, as dis
ID: 3557213 • Letter: D
Question
Don't fully grasp this: Assume you have a newly instantiated ArrayQueue, as discussed in class, whose internal array (0 based) has an initial capacity of 10 items. Assume the following commands are executed in the order shown:
enqueue("Adrian Peterson");
dequeue();
enqueue("Bryce Brown");
enqueue("Jamaal Charles");
dequeue();
dequeue();
enqueue("Alfred Morris");
enqueue("BenJarvus Green-Ellis");
enqueue("Fred Jackson");
enqueue("Shonn Greene");
dequeue();
enqueue("Ahmad Bradshaw");
dequeue();
enqueue("Marshawn Lynch");
enqueue("Colin Kaepernick");
dequeue();
enqueue("Pierre Thomas");
Indicate what the final state of the underlying array of the ArrayQueue is by matching the array index on the left with the value on the right that would be contained at that array index. Also indicate which item is at the front of the ArrayQueue and which item is at the rear of the ArrayQueue. The items on the right can be used more than once, if necessary
Adrian Peterson
Ahmad Bradshaw
Alfred Morris
BenJarvus Green-Ellis
Bryce Brown
Colin Kaepernick
Fred Jackson
Jamaal Charles
Marshawn Lynch
Pierre Thomas
Shonn Greene
null
Choices: 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - Item at Front - Item at End
A.Adrian Peterson
B.Ahmad Bradshaw
C.Alfred Morris
D.BenJarvus Green-Ellis
E.Bryce Brown
F.Colin Kaepernick
G.Fred Jackson
H.Jamaal Charles
I.Marshawn Lynch
J.Pierre Thomas
K.Shonn Greene
L.null
Explanation / Answer
Here queue is implemented through array whose size is 10.
we know queue based on first in first out principle insertion only possible at one end called rear and deletion is also possible only other end called front .initially front and rear is initialized =-1 if enqueue opertion is performed then rear is incremented by 1 and if dequeue opertion is performed then front is incremented by 1.it checks if front==rear then queue is empty and if rear<=max-1 then queue is overflow and if rear<=-1 then queue is underflow.
when given opertions is performed then rear and front value change at last enqueue opertion queue is overflow.so it could not store.
0-L NULL
1-L NULL
2-L NULL
3-L NULL
4-L NULL
5-L NULL
6-K Shonn Greene
7-B Ahmad Bradshaw
8-I Marshawn Lynch
9-F Colin Kaepernick
item at left :shonn greene
item at right:Colin kaepernick
ltem at front: NULL
item at rear:Colin Kaepernick
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.