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.

Array and two-dimensional array, Q. Describe the term array.  How do we rep...

Q. Describe the term array.  How do we represent two-dimensional arrays in memory?  Explain how we calculate the address of an element in a two dimensional array.

Explain the method of overlapping and intersecting, Overlapping or Interse...

Overlapping or Intersecting A polygon overlaps or intersects the current background if any of its sides cuts the edges of the viewport as depicted at the top right corner of th

Explain divide and conquer algorithms, Explain divide and conquer algorithm...

Explain divide and conquer algorithms  Divide  and  conquer  is  probably  the  best  known  general  algorithm  design  method.  It   work according to the following general p

How can the third dimension be displayed on the screen, How can the third d...

How can the third dimension be displayed on the screen The main problem in visualization is the display of three-dimensional objects and scenes on two-dimensional screens. How

Define the term ''complexity of an algorithm, Define the term 'complexity o...

Define the term 'complexity of an algorithm; Complexity of an algorithm is the calculate of analysis of algorithm. Analyzing an algorithm means predicting the resources that th

Applications of shortest path algorithms, The minimum cost spanning tree ha...

The minimum cost spanning tree has broad applications in distinct fields. It represents several complicated real world problems such as: 1. Minimum distance for travelling all o

#title.structured programming, what do you understand by structured program...

what do you understand by structured programming?explain with eg. top down and bottem up programming technique

How can a lock object be called in the transaction, How can a lock object b...

How can a lock object be called in the transaction? By calling Enqueue and Dequeue in the transaction.

Determine the complexity, 1)    The set of the algorithms whose order is O ...

1)    The set of the algorithms whose order is O (1) would run in the identical time.  True/False 2)    Determine the complexity of the following program into big O notation:

BST has two children, If a node in a BST has two children, then its inorder...

If a node in a BST has two children, then its inorder predecessor has No right child

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