A Brand Name ||Official Url :: Software UI Designer| Database Platform | OS | W€B | Server | Programming | Computing Technology ::

Stack Implementation : Operations In C

Stack Implementation Using linked list

A structure is created which includes integer variable (int data) and a pointer to the next element.
Since it is a stack an element can be inserted from top and removed from top only as it follows the Last In First Out (LIFO) principle.
While stack can be done imply using arrays yet we do using Linked list because an alternative has to be present and secondly Linked list provides dynamic memory allocation. In the program element is pushed using a push function and removed using a pop function created separately and called using a switch case.
Whats the advantages of using a SRUCT as a Node
 
It’s better to use an object so you could make a template an make this linked list very versatile because it can accept every object type as the data for the node. It will be like:
LinkedList<anobjectclass></anobjectclass>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s