Explain Difference Between Stack And Linked List Data Structures

Asked By 0 points N/A Posted on -
qa-featured

Please tell the difference between the stack and linked list in simple language? I did not understand their fundamental difference? How they both are different?

SHARE
Answered By 60 points N/A #287708

Explain Difference Between Stack And Linked List Data Structures

qa-featured

These both are Data Structures.

You can think of Stack as a bunch of books placed like the below image.

 

It represents a stack. As the stack is Last In First Out(LIFO), to get the book, which is on the floor, you have to start from up by taking one by one. That’s how Stack works.

q8

To understand Linked List, just think of train. Just like a train, Linked list has different nodes connected to each other. The formation of their connection depends on which type of Linked list you are implementing.

Hope you understand now.

Answered By 581745 points N/A #315857

Explain Difference Between Stack And Linked List Data Structures

qa-featured

A “Linked-List” is mainly a series of Nodes and every Node is composed of two things (2): one, the contents and two, the pointer to the next Node on the Linked-List. You can traverse or navigate the Linked-List by following the “next” pointers in every Node just like when following road directions from city to city.

A “stack”, on the other hand, is an abstract data type where you have two operations (2): one, “push” and two, “pop”. Pushing or push means putting an item in the stack while popping or pop means getting the first element of the stack or from the stack. When you push an item to a stack, the item is put or placed to the top.

It follows the “first in, last out” procedure. A stack is like trays in the cafeteria – you can only get the tray from the top of the stack or put a tray on top of the stack. The very first tray in the stack is actually the one at the very bottom, the last one to be used. A stack needs to store data that’s why it can be implemented or used as a Linked-List.

Login/Register to Answer

Related Questions