What is the difference between Stack and Queue data structure?

What is the difference between Stack and Queue data structure?

The primary difference between Stack and Queue data structure is that Stack is LIFO (Last In First Out), while Queue is a FIFO (First In First Out). Due to this, the manner in which each of these operate and the manner in which they handle data differs.

Stack

Queue

Type of data structure

Type of data structure

Follows Last In First Out (LIFO) order

Follows First In First Out (FIFO) order

Objects are inserted and removed at the same end.

Objects are inserted and removed from different ends.

The last inserted object is first to be accessed and extracted

The first object to be inserted is the first to be accessed and extracted.

Only one pointer is used. It points to the top of the stack.

Two different pointers are used. One for the front end and the other at the rear end.

Stack operations are called push and pop.

Queue operations are called enqueue and dequeue.

Are visualized as vertical collections

Are visualized as horizontal collections

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.