
Size: The operation prints the size of the queue that is the number of elements within the queue.Front: This operation prints out the first element of the queue (if the array is not empty).Display: This operation prints out all the elements of the queue (if the array is not empty), starting from the front index to the rear.Dequeue: This operation removes element(s) from the queue (if the array is not empty).Enqueue: This operation adds element(s) to the queue (if the array is not full).Int arr // N is the size (can be made dynamic)Ĭommon operations or function calls associated with the implementation of Queue are: array: an array to store elements of queue.a variable named rear (to store the position of the last element).a variable named front (to store the position of the first element).To define a queue using an array, we defined: However, the scope of this article does not cover other kinds of implementation only the implementation of the queue data structure using an array. Queues can be implemented using any of the three (3) data structures, namely Usually in situations like that, the first person on the queue would first be attended to, by the cashier - in similitude with the "FIFO" mechanism. Queues are often categorized as abstract data types and linear data structures which follow the First In First Out (FIFO) principle for the storage and retrieval of data, in which the first element inserted from one end of the array called the REAR is removed from the other end called the FRONT.Īnalogously, you could think of Queue as a queue of customers at a bank, waiting to withdraw or deposit cash.

Some examples of data structures in programming include arrays, trees, graphs, linked lists etc.

In computer science, a data structure is a format used to store, manage and organize data in an efficient manner enabling faster and easier access to the stored data. We have explained all operations in depth along with implementations.Ī Queue is a type of data structure used in programming, and like all data structures, it can used to store data. In this article, we will take a look into how we can implement Queue data structure using array.
