Condition required to detect queue full and queue empty-quiz question asked in interviews

For the operations given below in a circular queue of (n-1) capacity is implemented with an array of n elements. Condition required to detect queue full and queue empty are:

A) Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT

B) Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR

C) Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT

D) Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

Correct answer: Option A

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store