stack is LIFO means last in first out data structure.

the element added to last will be deleted first.

addition and deletion will takes at one end

example —

suppose we have a stack class.

after push(1) — adding element 1 — stack 1

after push(2) — adding element 2…

Inserting a node at the beginning of linked list

LinkedList is a linear data structure. a linked list is represented in memory with a node that have a data and link to next node.

we will use C# as a reference but concept will be same in all other languages.

Representation of node in code:

Node representation

LinkedList with CreateNode() and Print() Operation:

Rohit Kumar

i am software dev Lead passionate to explore new tech and solve complex problem in software

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store