What is the difference between a stack and a queue?
A comparison of stack and queue data structures, their differences in functionality and use cases.
A comparison of stack and queue data structures, their differences in functionality and use cases.
1 Answer
Umesh Sanjyal . 1 month ago
A linear data structure that stores items in a Last In, First Out (LIFO) order, This means the last item added to the stack is the first one removed is called stack. Example: Imagine a stack of books you put books on top, and you remove the top book first.
A linear data structure that stores items in a First In, First Out (FIFO) order, This means the first item added to the queue is the first one removed is called queue. Example: Think of people standing in a line the first person in line gets served first.