• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Stack Data Structure & It's Application
 

Stack Data Structure & It's Application

on

  • 9,906 views

 

Statistics

Views

Total Views
9,906
Views on SlideShare
9,905
Embed Views
1

Actions

Likes
6
Downloads
0
Comments
2

1 Embed 1

https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • thanks
    Are you sure you want to
    Your message goes here
    Processing…
  • nt bd
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Stack Data Structure & It's Application Stack Data Structure & It's Application Presentation Transcript

    • Stack Applications
    • What is stack ? Stack is a special type of data structure. Compared to a container. Last In First Out.
    • What is push ? Inserting a element into stack.
    • What is stack overflow ? Pushing elements when stack is full. When top exceeds size of stack .
    • Algorithm pushProcedure Push (Value)If TOP is equal to MAXOutput an error that the Stack is fullElseAdd 1 to TOPPut data in Value into TOP positionEnd IfEnd Procedure
    • What is pop ? Removing the top element from the stack.
    • What is stack underflow ? Performing pop operation when a stack is empty. When top equals zero.
    • Algorithm popProcedure PopIf TOP is equal to Zero thenStack is empty “Underflow”ElseOutput value from Stack at TOP positionSubtract 1 from TOPEnd IfEnd Procedure
    • Stack Applications
    • Applications of stack Start up & Shut down. Function calling. Argument passing in c.
    • System Startup
    • System Shutdown
    • Function calling
    • void three(){printf("Three startedn");printf("Three endedn");}void two(){printf("Two startedn");three();printf("Two endedn");}void one(){printf("One startedn");two();printf("One endedn");}void main(){clrscr();printf("Main startedn");one();printf("Main endedn");getch();}
    • OutputMain startedOne startedTwo startedThree startedThree endedTwo endedOne endedMain ended
    • Argument passing in C• Consider the following program :-# include <stdio.h># include <conio.h>void main(){int a=3;clrscr();printf(“%d %d%d%d”,a++,++a,++a,a++);getch();}Expected o/p.3566
    •  Buto/p is 6 6 5 3Because the argument are passed fromright to left in a stack and then sent toprintf function.
    • %d %d Top%d %d 6 Called function ie, printf(…); Here the input is taken from stack 6 So, the data order will be 6 6 5 3. 5 Therefore the o/p will be 6 6 5 3. 3
    • Conclusion Stack is one of the efficient way to implement discipline to system.
    • Thank You.