Structure of an array based queue
A queue is a linear data structure that only supports enqueue and dequeue operations to add and remove data items from the ends of the queue. This makes the array the perfect candidate to implement a queue. Most use cases can be solved using a bounded queue with a fixed size that cannot grow beyond that. Since we already know the queue size when creating it, we can use arrays to implement it.
Implementation of a queue using an array
State information
To implement a queue using an array, we must keep current information about the queue alongside the array that holds all the data items. This information is necessary to ensure all queue operations work as desired. Let us look at all the state information we need to maintain.
Liking the course? Check our discounted plans to continue learning.