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?

  1. A.

    rear =rear+1

  2. B.

    (rear+1) % max

  3. C.

    (rear % max) + 1

  4. 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.

Explore the full course: Coding For Placement