Data Structures · Question 10 · Medium

Data Structures question 10

A circular queue is implemented in an array of size n using front and rear indices, keeping one slot always empty to tell full from empty. Which condition means the queue is full?

  1. rear == front
  2. rear == n - 1
  3. (front + 1) % n == rear
  4. (rear + 1) % n == front
Answer and explanation

Answer: D. (rear + 1) % n == front

Explanation: With one slot kept empty, the queue is full when advancing rear by one (with wrap-around) would make it equal to front. rear == front is the empty condition.

Previous: What is the value of the postfix expression 6 2 3 + - 3 8 2 / + * ? · Next: Keys 15, 22, 8 and 29 are inserted in that order into an empty hash table of…

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge