What is Queue and how it is different from stack?
A Queue in the data structure is a linear structure which follows a particular order in which all operations to be performed. The order is First In First Out (FIFO) used in Queue.
S.no | Stack | Queue |
---|---|---|
1. | Stack has only one end for inserting and deleting the data elements | The queue has two terms, one for enqueuing the data and other for dequeuing the data elements. |
2. | There are no variants in Stack | In queue, there are variants like a circular queue, priority queue, double ended queue |
3. | Stack uses only one pointer for its one end. | Queue used 2 pointers for its two ends Rear and Front |
3. | Operations performed are Push() and Pop() | Operations performed are enqueue() and dequeue() |
BY Best Interview Question ON 02 Feb 2019