Tip:
Highlight text to annotate it
X
The answer of the quiz is D.
The first enqueue operation returns true because in a 2-element queue
where we haven't inserted many elements there's space to insert an element.
The second enqueue call succeeds for the same reason.
The third enqueue call fails and returns false, because there was no room left
in a 2-element queue after 2 enqueue operations had already succeeded.
Because we have a FIFO queue, the first dequeue operation returns the first element
that we'd added to the queue--that is to say 6,
the second dequeue operation returns 7,
and the third dequeue operation, which is now called on an empty queue, returns none.