Stack and Queue
Various problems related to Stacks and Queue
1. Queue
Queue is a FIFO data structure: the first element will be processed first. There are two important operations: enqueue and dequeue. We can use a dynamic array with two pointers to implement a queue.
We can use a queue to implement Breadth-first Search (BFS).
There are also some important extensions of the queue. For example,
Dequeue
Priority Queue
2. Stack
Stack is a LIFO data structure: the last element will be processed first. There are two important operations: push and pop. A dynamic array will be enough to implement a stack.
We use stack when LIFO principle is satisfied. Depth-first Search (DFS) is an important applications of stack.
Contents:-
ImplementationProblemsLast updated
Was this helpful?