Implementation of stack using linked lists, Data Structure & Algorithms

In the last subsection, we have implemented a stack by using an array. While a stack is implemented by using arrays, it suffers from the basic restriction of an array - i.e., its size cannot be increased or decreased once it is declared. Consequently, one ends up reserving either too much space or too less space for an array and in turn for a stack. This difficulty can be conquering if we implement a stack using a linked list. In the case of a linked stack, we will push and pop nodes from one end of any linked list.

The stack, as linked list is represented as a singly linked list. In the linked list each node contains the data & a pointer which gives location of the next node in the list. Program 2 implements a stack by using linked lists.

Posted Date: 4/10/2013 1:05:29 AM | Location : United States

Related Discussions:- Implementation of stack using linked lists, Assignment Help, Ask Question on Implementation of stack using linked lists, Get Answer, Expert's Help, Implementation of stack using linked lists Discussions

Write discussion on Implementation of stack using linked lists
Your posts are moderated
Related Questions
Binary Search Tree usage: Write a program to compare the time taken for a search in a skewed tree, a balanced tree, and a random tree. Speci cally, your program should do the

What is binary search?   Binary search is most useful when list is sorted. In binary search, element present in middle of the list is determined. If key (the number to search)

This is the most extensively used internal sorting algorithm. In its fundamental form, it was invented by C.A.R. Hoare in the year of 1960. Its popularity lies in the easiness of i

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

The most common way to insert nodes to a general tree is to first discover the desired parent of the node you desire to insert, and then insert the node to the parent's child list.

Define Merge Sort  Merge sort is a perfect example of a successful application of the divide and conquer method. It sorts a given array A[0...n-l] by separating it into two ha

Q. Suggest a method of implementing two stacks in one array such that as long as space is there in an array, you should be capable to add an element in either stack. Using proposed

Q. Give the adjacency matrix for the graph drawn below:                                                 Ans: Adjacency matrix for the graph given to us

Data Structure and Algorithm 1. Explain linked list and its types. How do you represent linked list in memory? 2. List and elucidate the types of binary tree. 3. Descr

We might sometimes seek a tradeoff among space & time complexity. For instance, we may have to select a data structure which requires a lot of storage to reduce the computation tim