Queue |
Stack |
---|
It follows FIFO (First In First Out) or LILO (Last In Last Out). | It follows LIFO (Last In First Out) or FILO (First In Last Out). |
The elements are inserted and removed from different ends.One for insertion, i.e. REAR END and one for deletion, i.e. FRONT END | The elements are inserted and removed at the same end i.e. TOP. |
Two different pointers are used for front end and rear end. | only one pointer is used. It points to the top of the stack. |
Basic operations are Enqueue (Insertion) and Dequeue (Deletion). | Basic operations are Push (Insertion) and Pop (Deletion). |
![Data Structures - Stack Vs Queue Queue](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMjAiIGhlaWdodD0iMTUwIiB2aWV3Qm94PSIwIDAgMzIwIDE1MCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgc3R5bGU9ImZpbGw6I2NmZDRkYjtmaWxsLW9wYWNpdHk6IDAuMTsiLz48L3N2Zz4=) | Queue |
| ![Data Structures - Stack Vs Queue Stack](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMTYiIGhlaWdodD0iMjMwIiB2aWV3Qm94PSIwIDAgMzE2IDIzMCI+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgc3R5bGU9ImZpbGw6I2NmZDRkYjtmaWxsLW9wYWNpdHk6IDAuMTsiLz48L3N2Zz4=) | Stack |
|