Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
 STACK
Introduction
Application
Conclusion
Khadijatul Kobra Shila
I.D:142-15-3616
A stack is a data structure that stores data in
such a way that the last piece of data stored, is
the first one retrieved....
All these applications follow the LIFO logic.
REAL LIFE: Stacks are present everyday life.From
the books in a library, to ...
#VISULAZE
STAGE:
TOP
Pile of Books
#SOURCE CODE:
void push(int *top, element
item)
{
/* add an item to the global
stack */
if (*top >=
MAX_STACK_SIZE-1) {
st...
Rahul Debnath
ID: 142-15-3484
RLATEDTO COMPUTER SCIENCE:
Below are a few applications of stacks in
computing.
#REVERSING STRING:
A simple application of...
E
S
R
E
V
E
R
REVERSE ESREVER
String is Reverse String
Stack
#VISULAZE
STAGE:
#define MAX 20
int top = -1;
char stack[MAX];
char pop();
void push(char);
main()
{
char str[20];
int i;
printf(“Enter the...
Abu Zafor Tomal
I.D:142-15-3816
#Calculator Methodology:
Every arithmetic operation in calculator follow
the stack postfix notation.
*
+
9 6 39+6*3
Equati...
Create Stack
While(not end of postfix notation){
ch = getch()
if(ch is operand)
push(ch)
else{
operand1 = pop()
operand2 =...
Abul Hasnath Limon
ID:142-15-3532
#Function ( recursive ):
A very good example of stack is Function.
Summation of positive integer can be implemented by
rec...
#include <stdio.h>
int sum(int n);
int main(){
int num,add;
printf("Enter a positive integer:n");
scanf("%d",&num);
add=su...
For better visualization of recursion in
this example:
sum(5)
=5+sum(4)
=5+4+sum(3)
=5+4+3+sum(2)
=5+4+3+2+sum(1)
=5+4+3+2...
Umme Habiba
ID:142-15-3677
Implementation : Palindrome
A palindrome is a word, phrase, number, or other sequence of
Characters which reads the same b...
C
I
V
I
C
C
I
V
I
C
PUSH POP
Stack Stack
Palindrome
Word
After pushing and popping, CIVIC word remain unchanged
#VISULAZE
...
Source code:
char stk[50];
int top=-1;
void push(char c){
top++;
stk[top]=c;
}
char pop(){
char c;
c=stk[top];
top–;
retur...
ThankYou
Project of data structure
Prochain SlideShare
Chargement dans…5
×
Prochain SlideShare
Data structures project
Suivant
Télécharger pour lire hors ligne et voir en mode plein écran

3

Partager

Télécharger pour lire hors ligne

Project of data structure

Télécharger pour lire hors ligne

application of data structure

Project of data structure

  1. 1.  STACK
  2. 2. Introduction Application Conclusion
  3. 3. Khadijatul Kobra Shila I.D:142-15-3616
  4. 4. A stack is a data structure that stores data in such a way that the last piece of data stored, is the first one retrieved. LAST IN FIRST OUT =LIFO To get the bottom plate out, you must first remove all the plates above. Example of stack
  5. 5. All these applications follow the LIFO logic. REAL LIFE: Stacks are present everyday life.From the books in a library, to the blank sheets of paper in a printer tray systems are used STACK to complete their acts. #PILES OF BOOKS: A book is added on top of a pile of books, while removing a book from a pile also takes the book on top of a pile in everywhere.
  6. 6. #VISULAZE STAGE: TOP Pile of Books
  7. 7. #SOURCE CODE: void push(int *top, element item) { /* add an item to the global stack */ if (*top >= MAX_STACK_SIZE-1) { stack_full( ); return; } stack[++*top] = item; } Push element pop(int *top) { /* return the top element from the stack */ if (*top == -1) return stack_empty( ); /* returns and error key */ return stack[(*top)--]; } Pop
  8. 8. Rahul Debnath ID: 142-15-3484
  9. 9. RLATEDTO COMPUTER SCIENCE: Below are a few applications of stacks in computing. #REVERSING STRING: A simple application of stack is reversing strings. To reverse a string , the characters of string are pushed onto the stack one by one as the string is read from left to right. To reverse the string ‘REVERSE’ the string is read from left to right and its characters are pushed.LIKE:
  10. 10. E S R E V E R REVERSE ESREVER String is Reverse String Stack #VISULAZE STAGE:
  11. 11. #define MAX 20 int top = -1; char stack[MAX]; char pop(); void push(char); main() { char str[20]; int i; printf(“Enter the string : ” ); gets(str); for(i=0;i<strlen(str);i++) push(str[i]); for(i=0;i<strlen(str);i++) str[i]=pop(); printf(“Reversed string is : “); puts(str); void push(char item){ if(top == (MAX-1)) { printf(“Stack Overflown”); return; } stack[++top] =item; }/*End of push()*/ char pop(){ if(top == -1) { printf(“Stack Underflown”); exit(1); } return stack[top–]; }
  12. 12. Abu Zafor Tomal I.D:142-15-3816
  13. 13. #Calculator Methodology: Every arithmetic operation in calculator follow the stack postfix notation. * + 9 6 39+6*3 Equation Postfix string Stack
  14. 14. Create Stack While(not end of postfix notation){ ch = getch() if(ch is operand) push(ch) else{ operand1 = pop() operand2 = pop() result = operand2 ch operand1 push(result) } } Result = pop()
  15. 15. Abul Hasnath Limon ID:142-15-3532
  16. 16. #Function ( recursive ): A very good example of stack is Function. Summation of positive integer can be implemented by recursive function and the functions are stored in a stack to maintain the sequence of summation. When a function is called within a function then the previous function is stored in a stack with it’s local variables. Summation of positive numbers with code example:
  17. 17. #include <stdio.h> int sum(int n); int main(){ int num,add; printf("Enter a positive integer:n"); scanf("%d",&num); add=sum(num); printf("sum=%d",add); } int sum(int n){ if(n==0) return n; else return n+sum(n-1); /*self call to function sum() */ } Enter a positive integer: 5 15 Output
  18. 18. For better visualization of recursion in this example: sum(5) =5+sum(4) =5+4+sum(3) =5+4+3+sum(2) =5+4+3+2+sum(1) =5+4+3+2+1+sum(0) =5+4+3+2+1+0 =5+4+3+2+1 =5+4+3+3 =5+4+6 =5+10 =15 Sum(1) Sum(2) Sum(3) Sum(4) Sum(5) All functions are pushed in stack
  19. 19. Umme Habiba ID:142-15-3677
  20. 20. Implementation : Palindrome A palindrome is a word, phrase, number, or other sequence of Characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. Suppose : ABCDCBA is a palindrome FGHHGF is a palindrome ASDFASDF is not a palindrome
  21. 21. C I V I C C I V I C PUSH POP Stack Stack Palindrome Word After pushing and popping, CIVIC word remain unchanged #VISULAZE STAGE:
  22. 22. Source code: char stk[50]; int top=-1; void push(char c){ top++; stk[top]=c; } char pop(){ char c; c=stk[top]; top–; return c; } void main(){ char in[30],b[30]; int i; printf(“nn ENTER UR STRINGt”); gets(in); for(i=0;in[i]!=‘’;i++){ push(in[i]); } i=0; while(top!=-1){ b[i]=pop(); i++; } b[i]=‘’; if(strcmp(in,b)==0){ printf (“n STRING is PALLINDROME”); } else{ printf (“n STRING IS NOT PALLNDROME”); } }
  23. 23. ThankYou
  • AkashSutradhar1

    Jul. 15, 2018
  • SeemaPathak8

    Nov. 7, 2016
  • 111gaurav

    Apr. 16, 2016

application of data structure

Vues

Nombre de vues

2 539

Sur Slideshare

0

À partir des intégrations

0

Nombre d'intégrations

4

Actions

Téléchargements

21

Partages

0

Commentaires

0

Mentions J'aime

3

×