Data Structures Question:

What is the relationship between a queue and its underlying array?

Tweet Share WhatsApp

Answer:

Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

Download Data Structures PDF Read All 48 Data Structures Questions
Previous QuestionNext Question
What is a queue in data structure?Which process places data at the back of the queue?