Define stack with proper insertion & deletion operation (BCA-3rd sem)


Stack definition

Stack is a linear data Structure in which a list of element may be insert or delete only one end know as top of the stack.It describe arrange operation that is first in last out or last in first out.There are two basic operation use in the stack.


Operation of stack

  • Push operation
  • Pop operation

Push operation

Enter new element in to a stack.

Pop operation

Delete an element from a stack.


The another operation define in stack know as peep which describe overflow & underflow condition occure in the stack.


Example for stack

Q.5,6,2,+,*,12,4,/,3,-?


Sol. 5  6/5  2/6/5  8/5  40  12/40  4/12/40  3/40   37.


Stack define the three type of notation

a. IN-FIX  (A+B)
b. PRE-FIX (+AB)
c. POST-FIX (AB+)


Overflow & Underflow condition

When data insert in to a stack but their are no space in the stack.

This situation known as overflow condition.
 Under flow  condition refers to situation where user delete data from a stack but stack is blank

what is Define inhertance click here


ALGORITHM OF STACK

A). Push Algorithm [ stack, top, max- value, item]
Step1. If top = max- value
                 Then print = overflow and return
Step 2. Set item = Stack [TOP]
Step 3. Set Top = top+1
Step 4. Exit


B). Pop Algorithm [ Stack, top, item]
Step 1. If   top = 0
                 Then print = underflow and return
Step 2. Set item = stack [TOP]

Step 3. Set Top = top -1 [Delete]

Step 4. Exit

             






1 comment:

If you have any doubts, Please lets me know and Please Follow our Website