Explain what is stack. describe ways to execute stack. , Data Structure & Algorithms

 

STACK is explained as follows:

A stack is one of the most usually used data structure. A stack is also called a Last-In-First-Out (LIFO) system, is a linear list in which insertion or deletion can take place only at one end called the top. This structure operates in the identical way as the stack of trays if we want to place another tray, it can be placed only at the top. Likewise, if we want to remove a tray from stack of trays, it can only be removed from the top. The insertion and removal operations in stack terminology are known as PUSH and POP operation.

369_stack.png 

(a)  Stack after the pushing of elements 8,10,12,5,6

(b) Stack after the popping of 2 elements.

Implementation of Stack is explained below

Stacks can be implemented in the below given two ways ways:

a)  Arrays is also implementation of stacks

b)  Linked List is also implementation of stacks

a)  Arrays:- To implement a stack we require a variable called top, that holds the index of the top element of stack and an array to hold the element of the stack.

For example:-     #define MAX 100

Typedef struct

{ int top;

int elements [MAX]

} stack;

b)  Linked List:- A stack represented by making use of a linked list is known as linked stack. The array based representation of stack suffers from the certain limitations.

        Size of stack must be known to us in advance

        Overflow condition may occur.

The linked representation allows a stack to develop to a limit of the computer's memory.

for example:-      typedef struct node

{

int info;

struct node * next;

} stack;

stack * top;

Posted Date: 7/13/2012 1:27:10 AM | Location : United States







Related Discussions:- Explain what is stack. describe ways to execute stack. , Assignment Help, Ask Question on Explain what is stack. describe ways to execute stack. , Get Answer, Expert's Help, Explain what is stack. describe ways to execute stack. Discussions

Write discussion on Explain what is stack. describe ways to execute stack.
Your posts are moderated
Related Questions
Define container in terms of  object-oriented terms A Container is a broad category whose instances are all more specific things; there is never anything which is just a Contai

WRITE AN ALGORITHM TO CONVERT PARENTHIZED INFIX TO POSTFIX FORM ALSO TRACE ALG ON ((A+B)*C-(D-E)$F+G)

Example 3: Travelling Salesman problem Given: n associated cities and distances among them Find: tour of minimum length that visits all of city. Solutions: How several

Explain Space Complexity Space Complexity :- The space complexity of an algorithm is the amount of memory it requires to run to completion. Some of the reasons to study space

Conversion of Forest into Tree A binary tree may be used to show an entire forest, since the next pointer in the root of a tree can be used to point to the next tree of the for


If a Dequeue is implemented via arrays, then this will suffer with the similar problems which a linear queue had suffered. Program 8 gives the array implementation of Dequeue.

(1)  (i) Add the special form let to the metacircular interpreter Hint: remember let is just syntactic sugar for a lambda expression and so a rewrite to the lambda form is all t

Q. Using array to execute the queue structure, write down an algorithm/program to (i) Insert an element in the queue. (ii) Delete an element from the queue.

Searching is the procedure of looking for something: Finding one piece of data that has been stored inside a whole group of data. It is frequently the most time-consuming part of m