Consider the following queue of character, implemented using array of 7…
2023
Consider the following queue of character, implemented using array of 7 memory, Front = 3 Rear = 4 Queue: –, –, A, B, , ___ , where ‘–’, denote empty memory cell. What is the value of front and rear after the following operation?
Enqueue C, D Dequeue Enqueue E, F Dequeue
- A.
Front = 3 Rear = 6
- B.
Front = 4 Rear = 7
- C.
Front = 5 Rear = 1
- D.
Front = 1 Rear = 4
Attempted by 92 students.
Show answer & explanation
Correct answer: C
Initial front = 3 and rear = 4.
After enqueue C and D, rear moves to 6. After one dequeue, front moves to 4.
After enqueue E and F in a circular array of size 7, rear moves to 1. After the final dequeue, front moves to 5.
Therefore, Front = 5 and Rear = 1.