Stacks | Queues |
Stack is a heap of elements placed one over the other | Queue is a set of elements placed one after the other |
Stack mechanism is known as Last In First Out (LIFO) | Queue mechanism is known as First In First Out (FIFO) |
Stack is mainly characterized by “top” which refers to its top element. | Queue is mainly characterized by “front” and rear, which refers to its first and last elements. |
Both insertion and deletion occur at the same end i.e. at the top. | Insertion and deletion occur at two different ends i.e. insertion at rear and deletion at front. |
If there is no value at the top, stack is said to be empty. | If front=rear, queue is said to be empty. |
The common terms associated with stack are : push, pop, top, isfull, isempty. | The common terms associated with queue are: qinsert, qdelete, front, rear, isfull, isempty. |
|
|
Stack can be implemented using both arrays and linked lists. | Queue also can be implemented using both arrays and linked lists. |
This has no sub types | It has sub types such as: simple queue, circular queue, double-ended queue, priority queue. |
![]() |
Differences between Stacks queues: |
You might also like:
Subject :
Java
0 comments:
Post a Comment