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.

Asymptotic notation, Asymptotic notation Let us describe a few function...

Asymptotic notation Let us describe a few functions in terms of above asymptotic notation. Example: f(n) = 3n 3 + 2n 2 + 4n + 3 = 3n 3 + 2n 2 + O (n), as 4n + 3 is of

Illustrate the visual realism applications, Illustrate the Visual realism a...

Illustrate the Visual realism applications a)   Robot Simulations : Visualization of movement of their links and joints  and end effector movement etc. b)  CNC programs ver

Binary tree construction, Construct a B+ tree for the following keys, start...

Construct a B+ tree for the following keys, starting with an empty tree.  Each node in the tree can hold a maximum of 2 entries (i.e., order d = 1). Start with an empty root nod

Define approximating smooth surfaces with polygon nets, Approximating smoot...

Approximating smooth surfaces with Polygon nets Networks of polygons are used to represent smooth surfaces. They are, of course, only an approximation to the true surface, but

Determine the effect of ruby in implementation of string, Determine the eff...

Determine the effect of Ruby in implementation of string Ruby has a String class whose instances are mutable sequences of Unicode characters. Symbol class instances are charact

Delete a given specific node from a doubly linked list. , D elete a specif...

D elete a specific Node from Double Linked List as follows DELETEDBL(INFO, FORW, BACK, START, AVAIL,LOC) 1. [Delete Node] Set FORW [ BACK [LOC]]:= FORW[LOC]& BACK [FORW[

Explain the term heuristics searching, (a) Discuss the role played by Busin...

(a) Discuss the role played by Business Intelligence Systems in giving companies strategic advantage. (b) Explain the term heuristics searching . (c) With the use of an appr

Create a binary tree , Create a class "box" that will contain a random inte...

Create a class "box" that will contain a random integer value v such that O

Creation of doubly linked list, Program: Creation of Doubly Linked List ...

Program: Creation of Doubly Linked List OUTPUT Input the values of the element -1111 to come out : 1 Input the values of the element -1111 to come out : 2 Inpu

Explain optimal binary search trees, Explain Optimal Binary Search Trees ...

Explain Optimal Binary Search Trees One of the principal application of Binary Search Tree is to execute the operation of searching. If probabilities of searching for elements

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