Friday 15 May 2020

Stack ADT and Basic Condition


A stack is a linear list in which insertion and removals take place at one end called top of the stack. (OR)

A stack is an ordered collection of homogeneous data elements where the insertion and deletion take place at one end only.


·  
·       
  1. A stack is a linear data structure.
  2. The insertion operation is called push operation and delectation operation is called pop operation.
  3. The following are different statuses of stack, when stack contain ‘N’ elements 

  1.      When the stack is empty, trying to perform pop() operation causes an exception “StackUnderFlow”
  2. When the stack is full, trying to perform push() operation causes an exception “StackUnderFlow”
  3. When push() operation is performed ‘top’ will be incremented by one; similarly when pop() is performed ‘top’ is decremented by one.
  4. ‘top’ is a pointer which indicates the status of stack and topmost element on stack.
Stack ADT

A stack is an abstract data type that supports following methods

AbstractDataType stack
{

    Instances: Linear list of elements; one end is called the bottom; and other is the top
 Operations:
        Stack(): creates a new stack that is empty. It needs no parameters and returns an empty stack.
  push(item): adds a new item to the top of the stack. It needs the item and returns nothing.
          pop(): removes the top item from the stack. It needs no parameters and returns the item.
                     The stack is modified.
          peek(): returns the top item from the stack but does not remove it. It needs no parameters.
                      The stack is not modified.
      isEmpty(): tests to see whether the stack is empty. It needs no parameters and returns a Boolean value.
             size(): returns the number of items on the stack. It needs no parameters and returns an integer.
}



0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top