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

Assignment Help:

 

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;


Related Discussions:- Explain what is stack. describe ways to execute stack.

Sequential search of a list is preferred over binary search, What are the c...

What are the conditions under which sequential search of a list is preferred over binary search? Sequential Search is a preferred over binary search when the list is unordered

Explain the sum of subset problem, a. Explain the sum of subset problem. Ap...

a. Explain the sum of subset problem. Apply backtracking to solve the following instance of sum of subset problem: w= (3, 4, 5, 6} and d = 13. Briefly define the method using a sta

A Booth''s, Draw a flowchart of a Booth''s multiplication algorithm and exp...

Draw a flowchart of a Booth''s multiplication algorithm and explain it.

First class Abstract data type , 3. A function to convert a complex number ...

3. A function to convert a complex number in algebraic form to a complex number in phasor form

State z-buffer algorithm, Z-Buffer Algorithm Also known as the Depth-Bu...

Z-Buffer Algorithm Also known as the Depth-Buffer algorithm, this image-space method simply selects for  display the polygon or portion of a polygon that is nearest to the view

Depth-first search (dfs) , In this respect depth-first search (DFS) is the...

In this respect depth-first search (DFS) is the exact reverse process: whenever it sends a new node, it immediately continues to extend from it. It sends back to previously explore

Linked list, write an algorithm for multiplication of two sparse matrices u...

write an algorithm for multiplication of two sparse matrices using Linked Lists

State in brief about assertion, State  in brief about assertion Asser...

State  in brief about assertion Assertion: A statement which should be true at a designated point in a program.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd