logo

Crowdly

Browser

Add to Chrome

Consider an array implementation of a circular queue. Let the array be named Q a...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Consider an array implementation of a circular queue. Let the array be named Q and be of size N=10, and hence the indices range between 0 and 9, including both. Let the front of the queue be indexed by f and the rear be indexed by r. Initially, when the queue is empty, let f = r = N-1 = 9.

With every enqueue operation, we do r = r + 1 mod N and store the new element at index r of the array.

With every dequeue operation, we do f = f + 1 mod N and remove the element at position f.

What will be values of f, r, Q[f+1] and Q[r] after the following operations?

enqueue 4; enqueue 6; enqueue 2; dequeue; enqueue 3; enqueue 9; enqueue 5; dequeue;

50%
0%
0%
50%
More questions like this

Want instant access to all verified answers on moodle.kent.ac.uk?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome