SlideShare a Scribd company logo
Project of data structure
 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.
LAST IN FIRST OUT =LIFO
To get the bottom plate out,
you must first remove all
the plates above.
Example of stack
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.
#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) {
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
Rahul Debnath
ID: 142-15-3484
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:
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 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–];
}
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
Equation
Postfix string
Stack
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()
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
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:
#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
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
Umme Habiba
ID:142-15-3677
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
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:
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”);
}
}
ThankYou

More Related Content

PPTX
Stack - Data Structure - Notes
PDF
PPTX
Linked list
PPTX
heap Sort Algorithm
PPS
Virtual memory
PPTX
PPSX
PPTX
Stack and Queue
Stack - Data Structure - Notes
Linked list
heap Sort Algorithm
Virtual memory
Stack and Queue

What's hot (20)

PPTX
Infix to postfix conversion
PPT
PPTX
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
PPTX
Introduction to data structure ppt
PPTX
stack & queue
PPTX
Doubly Linked List
PPTX
Circular link list.ppt
PPSX
Data Structure (Queue)
PPTX
Stacks IN DATA STRUCTURES
PPTX
Linked List
PPTX
Polish Notation In Data Structure
PPTX
sorting and its types
PPTX
Conversion of Infix to Prefix and Postfix with Stack
PPTX
Stack data structure
PPT
Linked List
PPTX
STACKS IN DATASTRUCTURE
PPTX
Prefix, Infix and Post-fix Notations
PPT
Data structures using c
PPTX
Dynamic memory allocation
Infix to postfix conversion
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Introduction to data structure ppt
stack & queue
Doubly Linked List
Circular link list.ppt
Data Structure (Queue)
Stacks IN DATA STRUCTURES
Linked List
Polish Notation In Data Structure
sorting and its types
Conversion of Infix to Prefix and Postfix with Stack
Stack data structure
Linked List
STACKS IN DATASTRUCTURE
Prefix, Infix and Post-fix Notations
Data structures using c
Dynamic memory allocation
Ad

Viewers also liked (19)

DOC
Data structures project
PPTX
DS_Final_Project
PPTX
Library management in Data structure
PPTX
Garrage management system
PPTX
Calendar c
PPTX
Data structures' project
PPTX
Simple Calendar Application using C
PDF
62 how to track someone elses line messages
PPTX
Costume analysis
PDF
آشنایی با زیرساخت کلید عمومی (PKI)
PDF
how to spy on husbands line messages
PPT
งานนำเสนชุมชน (แก้ไข)
DOCX
Biochemistry
PPTX
Algo labpresentation a_group
PPTX
Erick hernandez
PDF
how to hack my husbands LINE
PDF
how to track line chat remotely
PDF
how to spy on LINE chat history
PDF
how to spy on LINE messages
Data structures project
DS_Final_Project
Library management in Data structure
Garrage management system
Calendar c
Data structures' project
Simple Calendar Application using C
62 how to track someone elses line messages
Costume analysis
آشنایی با زیرساخت کلید عمومی (PKI)
how to spy on husbands line messages
งานนำเสนชุมชน (แก้ไข)
Biochemistry
Algo labpresentation a_group
Erick hernandez
how to hack my husbands LINE
how to track line chat remotely
how to spy on LINE chat history
how to spy on LINE messages
Ad

Similar to Project of data structure (20)

PDF
PDF
04 stacks
PDF
Data structures stacks
PPTX
Stack and its applications
PPTX
Stack and Queue.pptx university exam preparation
PPTX
Data Structure.pptx
PPTX
Stack data structure
PPTX
Stack.pptx
PDF
Stacks
PPTX
STACK1.pptx
PPT
Lec 4 Stack of Data Structures & Algorithms
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
PDF
Data structure lab manual
PPT
MO 2020 DS Stacks 1 AB.ppt
PPTX
Abscddnddmdkwkkstack implementation.pptx
PPT
Stack linked list
PPTX
Stacks in c++
PPTX
STACKS implimentarions AND stack applications .pptx
PPTX
introduction of the Stacks and Queues.pptx
PPTX
Data Structures and Agorithm: DS 06 Stack.pptx
04 stacks
Data structures stacks
Stack and its applications
Stack and Queue.pptx university exam preparation
Data Structure.pptx
Stack data structure
Stack.pptx
Stacks
STACK1.pptx
Lec 4 Stack of Data Structures & Algorithms
6 - STACKS in Data Structure and Algorithm.pptx
Data structure lab manual
MO 2020 DS Stacks 1 AB.ppt
Abscddnddmdkwkkstack implementation.pptx
Stack linked list
Stacks in c++
STACKS implimentarions AND stack applications .pptx
introduction of the Stacks and Queues.pptx
Data Structures and Agorithm: DS 06 Stack.pptx

More from Umme habiba (20)

DOCX
Compiler lab final report writing
PPTX
online bus ticket booking system
PPTX
online bus ticket booking system
PPTX
online bus ticket booking system
PPT
Accounting adjusting
DOCX
Economic.assignment
DOCX
Major economic problems of bangladesh
PPT
Overview of various types of operating system
DOCX
Os lab report(shell coding)
PPTX
Ecommerce(online Shopping)
DOCX
Different types of Addressing.cao
PPTX
2nd generation of computer
DOCX
Art_of_living assignment
PPTX
Art_of_living
DOCX
Informationsecurity
PPT
SQL Joinning.Database
PPTX
WLAN of networking.ppt
PPTX
simpson's in numerical method
PPTX
Error detection in Data comunication
PPTX
microsoft word & powerpoint
Compiler lab final report writing
online bus ticket booking system
online bus ticket booking system
online bus ticket booking system
Accounting adjusting
Economic.assignment
Major economic problems of bangladesh
Overview of various types of operating system
Os lab report(shell coding)
Ecommerce(online Shopping)
Different types of Addressing.cao
2nd generation of computer
Art_of_living assignment
Art_of_living
Informationsecurity
SQL Joinning.Database
WLAN of networking.ppt
simpson's in numerical method
Error detection in Data comunication
microsoft word & powerpoint

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Welding lecture in detail for understanding
PDF
Well-logging-methods_new................
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPT
Mechanical Engineering MATERIALS Selection
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
PPT on Performance Review to get promotions
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Construction Project Organization Group 2.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
bas. eng. economics group 4 presentation 1.pptx
Welding lecture in detail for understanding
Well-logging-methods_new................
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Mechanical Engineering MATERIALS Selection
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Lesson 3_Tessellation.pptx finite Mathematics
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT on Performance Review to get promotions
OOP with Java - Java Introduction (Basics)
UNIT 4 Total Quality Management .pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Construction Project Organization Group 2.pptx

Project of data structure

  • 5. 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
  • 6. 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.
  • 8. #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
  • 10. 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:
  • 11. E S R E V E R REVERSE ESREVER String is Reverse String Stack #VISULAZE STAGE:
  • 12. #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–]; }
  • 14. #Calculator Methodology: Every arithmetic operation in calculator follow the stack postfix notation. * + 9 6 39+6*3 Equation Postfix string Stack
  • 15. 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()
  • 17. #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:
  • 18. #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
  • 19. 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
  • 21. 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
  • 22. 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:
  • 23. 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”); } }