Introduction and Array Implementation of Queue Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Similar to Stack, Queue is a linear data structure that follows a particular order in which the operations are performed for storing data. The order is First In First Out (FIFO). One can imagine a queue as a line of people waiting to receive something in sequential order which starts from the beginning of the line. It is an ordered list in which insertions are done at one end which is known as the rear and deletions are done from the other end known as the front. A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first. The difference between stack and queue is in removing an element. In a stack we remove the item that is most recently added while in a queue, we remove the item that is least recently added.Queue Data structureSimple Array implementation Of Queue:For implementing the queue, we only need to keep track of two variables: front and size. We can find the rear as front + size - 1.The Enqueue operation is simple, we simply insert at the end of the array. This operation takes O(1) timeThe Dequeue operation is costly as we need remove from the beginning of the array. To remove an item, we need to move all items one position back. Hence this operations takes O(n) time.If we do otherwise that insert at the begin and delete from the end, then insert would become costly.Please refer Simple Array implementation of Queue for implementation.Operations ComplexityEnqueue (insertion) O(1)Deque (deletion) O(n)Front (Get front) O(1)Rear (Get Rear)O(1)IsFull (Check queue is full or not)O(1)IsEmpty (Check queue is empty or not)O(1)Circular Array implementation Of Queue:We can make all operations in O(1) time using circular array implementation. The idea is to treat the array as a circular buffer. We move front and rear using modular arithmeticWhen we insert an item, we increment front using modular arithmetic (which might leave some free space at the beginning of the array).When we delete an item, we decrement rear using modular arithmetic.Please refer Circular Array implementation Of Queue for details of implementationOperations ComplexityEnqueue (insertion) O(1)Deque (deletion) O(1)Front (Get front) O(1)Rear (Get Rear)O(1)IsFull (Check queue is full or not)O(1)IsEmpty (Check queue is empty or not)O(1) Comment More info K kartik Follow Improve Article Tags : Queue DSA Arrays Goldman Sachs Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like