Which one of the following is the correct way to increment the rear end in a…
2025
Which one of the following is the correct way to increment the rear end in a circular queue?
- A.
rear =rear+1
- B.
(rear+1) % max
- C.
(rear % max) + 1
- D.
None of the above
Attempted by 265 students.
Show answer & explanation
Correct answer: B
Answer: b
Explanation: The answer is b. It ensures that the rear will have the value from 0 to max-1; if the rear end points to the last position, and we increment the rear end using (rear+1) % max, then rear will point to the first position in the queue.