CREATED BY “SYED SALMAN JILANI“
AND COMPANIONS
GROUPNAME : GUNS & ROSES
STACK
TABLE OF CONTENTS
DEFINE STACK
EXAMPLES
OVERFLOW UNDEFLOW
ADDITIONAL OPERATION
DEFINE STACK
 A stack is a container of objects that
are inserted and removed according
to the last-in first-out (LIFO) principle
 There are two Basic functions of stack
 PUSH & POP
 Stack is a Limited Access Data structure
EXAMPLES
 There are some real life Examples of Stack to
understand its structure
 Stack of Assignment Files Rings Pole and Gun
Magazines
OVERFLOW & UNDERFLOW
 A STACK cannot grow indefinitely because there is
always a limit to memory when it comes to limit and yet
another operation tries to PUSH data into the stack then
a stack overflow occurs
 If the stack is Empty and yet a pop operation attempt
this is called underflow
 Additional function are used to stop further PUSH & POP
ADDITIONAL OPERATIONS
 Duplicate: the top item is popped, and then pushed again
(twice), so that an additional copy of the former top item is
now on top, with the original below it
 Peek: the topmost item is returned but the stack pointer is not
changed that the item remains on the stack This is also
called top
 Swap or exchange: the two topmost items on the stack
exchange places
 Rotate (or Roll): the n topmost items are moved on the stack
in a rotating fashion.
Stack

Stack

  • 2.
    CREATED BY “SYEDSALMAN JILANI“ AND COMPANIONS GROUPNAME : GUNS & ROSES
  • 3.
    STACK TABLE OF CONTENTS DEFINESTACK EXAMPLES OVERFLOW UNDEFLOW ADDITIONAL OPERATION
  • 4.
    DEFINE STACK  Astack is a container of objects that are inserted and removed according to the last-in first-out (LIFO) principle  There are two Basic functions of stack  PUSH & POP  Stack is a Limited Access Data structure
  • 5.
    EXAMPLES  There aresome real life Examples of Stack to understand its structure  Stack of Assignment Files Rings Pole and Gun Magazines
  • 6.
    OVERFLOW & UNDERFLOW A STACK cannot grow indefinitely because there is always a limit to memory when it comes to limit and yet another operation tries to PUSH data into the stack then a stack overflow occurs  If the stack is Empty and yet a pop operation attempt this is called underflow  Additional function are used to stop further PUSH & POP
  • 7.
    ADDITIONAL OPERATIONS  Duplicate:the top item is popped, and then pushed again (twice), so that an additional copy of the former top item is now on top, with the original below it  Peek: the topmost item is returned but the stack pointer is not changed that the item remains on the stack This is also called top  Swap or exchange: the two topmost items on the stack exchange places  Rotate (or Roll): the n topmost items are moved on the stack in a rotating fashion.