STACK DATASTRUCTURE
BY:
KAVYA
STACK
• Stack is a,
Last in First Out or First in Last out,
Linear,
Non-primitive,
Data +Structure.
What exactly these points are, lets elaborate one by one in
bottom up approach
Data Structure: is a specialized format for organizing and storing the data in memory
and accessing the data from the memory
Classification of Data Structure
Definition of Data Structure also defined as, process of storing and accessing the
stored data from the memory in very efficient manner, efficiency in the matter of
space and time
Primitive Data Structure:
-data structures that are directly operated upon the machine-level instructions
-i.e., data structure which supports the basic data types such as: int, float, char, pointers,
constants.
Non-primitive Data Structure:
- Data structures are derived from the primitive data structures
-Structuring the group of homogeneous (same data type) or heterogeneous(different data
type)
Examples: Arrays, List, Files
Non-Primitive classified into 2 types:
1.Linear:
data structure which support homogeneous data elements.
data elements are stored in the memory sequentially in other words there is
adjacency link between the data elements
examples: Stack, Queue, Linked list
2.Non-Linear:
data items are connected to several other items.
relationship between the data elements are in the fashion of parent-child
examples: Graph, Tree
Stack is linear data structure which follows a particular order in
which the operations are performed.
EXAMPLES:
•STACK OF BOOKS ON DESK
•STACK OF PLATES IN A CAFETERIA
•STCAK OF COINS,CHAIRS,ETC..,
OPERATIONS ON STACK
•PUSH(): Place a new element into the stack. The value provided
becomes the new topmost item in the stack
•POP(): Remove the topmost item from the stack.
PUSH()
ALGORITHM TO PUSH AN ELEMENT ONTO STACK
PUSH(S,TOP,SIZE,ITEM)
1.IF TOP == MAX THEN
write(‘stack is full or overflow’) and exit
2. TOP=TOP+1
3. S[TOP]=ITEM
4. EXIT
POP()
ALGORITHM TO POP AN ELEMENT ONTO STACK
POP(S,TOP,SIZE)
1.IF TOP == -1 THEN
write(‘stack is EMPTY or UNDERFLOW’) and exit
2. VALUE=S[TOP]
3. TOP=TOP-1
4. EXIT
APPLICATIONS OF STACK
•Back and Forward Buttons in a Web Browser
•Undo and Redo button of MS-word
•Evaluating Arithmetic operations
•Recursion
THANK YOU

Introduction to stack

  • 1.
  • 2.
    STACK • Stack isa, Last in First Out or First in Last out, Linear, Non-primitive, Data +Structure. What exactly these points are, lets elaborate one by one in bottom up approach
  • 3.
    Data Structure: isa specialized format for organizing and storing the data in memory and accessing the data from the memory Classification of Data Structure Definition of Data Structure also defined as, process of storing and accessing the stored data from the memory in very efficient manner, efficiency in the matter of space and time
  • 4.
    Primitive Data Structure: -datastructures that are directly operated upon the machine-level instructions -i.e., data structure which supports the basic data types such as: int, float, char, pointers, constants. Non-primitive Data Structure: - Data structures are derived from the primitive data structures -Structuring the group of homogeneous (same data type) or heterogeneous(different data type) Examples: Arrays, List, Files Non-Primitive classified into 2 types: 1.Linear: data structure which support homogeneous data elements. data elements are stored in the memory sequentially in other words there is adjacency link between the data elements examples: Stack, Queue, Linked list 2.Non-Linear: data items are connected to several other items. relationship between the data elements are in the fashion of parent-child examples: Graph, Tree
  • 5.
    Stack is lineardata structure which follows a particular order in which the operations are performed. EXAMPLES: •STACK OF BOOKS ON DESK •STACK OF PLATES IN A CAFETERIA •STCAK OF COINS,CHAIRS,ETC..,
  • 6.
    OPERATIONS ON STACK •PUSH():Place a new element into the stack. The value provided becomes the new topmost item in the stack •POP(): Remove the topmost item from the stack.
  • 7.
    PUSH() ALGORITHM TO PUSHAN ELEMENT ONTO STACK PUSH(S,TOP,SIZE,ITEM) 1.IF TOP == MAX THEN write(‘stack is full or overflow’) and exit 2. TOP=TOP+1 3. S[TOP]=ITEM 4. EXIT
  • 8.
    POP() ALGORITHM TO POPAN ELEMENT ONTO STACK POP(S,TOP,SIZE) 1.IF TOP == -1 THEN write(‘stack is EMPTY or UNDERFLOW’) and exit 2. VALUE=S[TOP] 3. TOP=TOP-1 4. EXIT
  • 9.
    APPLICATIONS OF STACK •Backand Forward Buttons in a Web Browser •Undo and Redo button of MS-word •Evaluating Arithmetic operations •Recursion
  • 10.