Multiple choice

Given a circular queu |||||||| |---|---|---|---|---|---|---| | | | Rear | | | | Front | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | A | B | C | | | | | After the following operations, what will be the positions of front and rear? Insert(Q,X), Insert(Q,Y), Remove(Q), Insert(Q,Z) Insert(Q,D), Insert(Q,E)

  1. Rear =1, Front = 1

  2. Rear = 1, Front = 7

  3. Rear = 1, Front = 2

  4. Queue overflows

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Initial: Rear=2, Front=6. Size is 3 (A, B, C). Insert(X), Insert(Y): Rear=4. Remove(): Front=7. Insert(Z), Insert(D), Insert(E): Rear=7. The queue is full.