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

What's hot (20)

PDF
sparse matrix in data structure
MAHALAKSHMI P
 
PPSX
Stack
Seema Sharma
 
DOCX
Java questions for viva
Vipul Naik
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
PPTX
Queues
Ashim Lamichhane
 
PPTX
Call by value
Dharani G
 
PPT
stack presentation
Shivalik college of engineering
 
PPTX
stack & queue
manju rani
 
PPTX
Chapter 16 Dictionaries
Praveen M Jigajinni
 
PPTX
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
PPTX
Java Tokens
Madishetty Prathibha
 
PPTX
Stack organization
chauhankapil
 
PDF
Python tuple
Mohammed Sikander
 
PPTX
Phone Book project in Data Structure C
VaithekyAnandarajah
 
PPS
Java Exception handling
kamal kotecha
 
PPTX
Stack and its operations
V.V.Vanniaperumal College for Women
 
PPTX
Stack project
Amr Aboelgood
 
PPT
Stacks
sweta dargad
 
PPTX
This pointer
Kamal Acharya
 
PPT
Stack a Data Structure
ForwardBlog Enewzletter
 
sparse matrix in data structure
MAHALAKSHMI P
 
Java questions for viva
Vipul Naik
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Call by value
Dharani G
 
stack & queue
manju rani
 
Chapter 16 Dictionaries
Praveen M Jigajinni
 
Prefix, Infix and Post-fix Notations
Afaq Mansoor Khan
 
Stack organization
chauhankapil
 
Python tuple
Mohammed Sikander
 
Phone Book project in Data Structure C
VaithekyAnandarajah
 
Java Exception handling
kamal kotecha
 
Stack and its operations
V.V.Vanniaperumal College for Women
 
Stack project
Amr Aboelgood
 
Stacks
sweta dargad
 
This pointer
Kamal Acharya
 
Stack a Data Structure
ForwardBlog Enewzletter
 

Viewers also liked (19)

DOC
Data structures project
sachinrajsachin
 
PPTX
DS_Final_Project
星星 孫
 
PPTX
Library management in Data structure
harshil1902
 
PPTX
Garrage management system
Prateek Pandey
 
PPTX
Calendar c
Shanellebyrd
 
PPTX
Data structures' project
Behappy Seehappy
 
PPTX
Simple Calendar Application using C
codewithc
 
PDF
62 how to track someone elses line messages
CatherineRai
 
PPTX
Costume analysis
HannahO4997
 
PDF
آشنایی با زیرساخت کلید عمومی (PKI)
مرکز دولتی صدور گواهی الکترونیکی ریشه
 
PDF
how to spy on husbands line messages
CatherineRai
 
PPT
งานนำเสนชุมชน (แก้ไข)
Blsaw Wannarat
 
DOCX
Biochemistry
qalikn
 
PPTX
Algo labpresentation a_group
Umme habiba
 
PPTX
Erick hernandez
ErickHernandez1020
 
PDF
how to hack my husbands LINE
CatherineRai
 
PDF
how to track line chat remotely
CatherineRai
 
PDF
how to spy on LINE chat history
CatherineRai
 
PDF
how to spy on LINE messages
CatherineRai
 
Data structures project
sachinrajsachin
 
DS_Final_Project
星星 孫
 
Library management in Data structure
harshil1902
 
Garrage management system
Prateek Pandey
 
Calendar c
Shanellebyrd
 
Data structures' project
Behappy Seehappy
 
Simple Calendar Application using C
codewithc
 
62 how to track someone elses line messages
CatherineRai
 
Costume analysis
HannahO4997
 
آشنایی با زیرساخت کلید عمومی (PKI)
مرکز دولتی صدور گواهی الکترونیکی ریشه
 
how to spy on husbands line messages
CatherineRai
 
งานนำเสนชุมชน (แก้ไข)
Blsaw Wannarat
 
Biochemistry
qalikn
 
Algo labpresentation a_group
Umme habiba
 
Erick hernandez
ErickHernandez1020
 
how to hack my husbands LINE
CatherineRai
 
how to track line chat remotely
CatherineRai
 
how to spy on LINE chat history
CatherineRai
 
how to spy on LINE messages
CatherineRai
 
Ad

Similar to Project of data structure (20)

PDF
Stack
Amrutha Rajan
 
PDF
04 stacks
Rajan Gautam
 
PDF
Data structures stacks
maamir farooq
 
PPTX
Stack and its applications
Ahsan Mansiv
 
PPTX
Stack and Queue.pptx university exam preparation
RAtna29
 
PPTX
Data Structure.pptx
SajalFayyaz
 
PPTX
Stack data structure
rogineojerio020496
 
PPTX
Stack.pptx
AliRaza899305
 
PDF
Stacks
Sadaf Ismail
 
PPTX
STACK1.pptx
MouDhara1
 
PPT
Lec 4 Stack of Data Structures & Algorithms
haseebanjum2611
 
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
PDF
Data structure lab manual
nikshaikh786
 
PPT
MO 2020 DS Stacks 1 AB.ppt
shashankbhadouria4
 
PPTX
Abscddnddmdkwkkstack implementation.pptx
zainshahid3040
 
PPT
Stack linked list
bhargav0077
 
PPTX
Stacks in c++
Vineeta Garg
 
PPTX
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
PDF
Stack
Zaid Shabbir
 
PPTX
introduction of the Stacks and Queues.pptx
kavitashingi123
 
04 stacks
Rajan Gautam
 
Data structures stacks
maamir farooq
 
Stack and its applications
Ahsan Mansiv
 
Stack and Queue.pptx university exam preparation
RAtna29
 
Data Structure.pptx
SajalFayyaz
 
Stack data structure
rogineojerio020496
 
Stack.pptx
AliRaza899305
 
Stacks
Sadaf Ismail
 
STACK1.pptx
MouDhara1
 
Lec 4 Stack of Data Structures & Algorithms
haseebanjum2611
 
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
Data structure lab manual
nikshaikh786
 
MO 2020 DS Stacks 1 AB.ppt
shashankbhadouria4
 
Abscddnddmdkwkkstack implementation.pptx
zainshahid3040
 
Stack linked list
bhargav0077
 
Stacks in c++
Vineeta Garg
 
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
introduction of the Stacks and Queues.pptx
kavitashingi123
 
Ad

More from Umme habiba (20)

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

Recently uploaded (20)

PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
PPTX
darshai cross section and river section analysis
muk7971
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PDF
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
PPTX
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
PDF
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
PPTX
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
PPTX
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
PDF
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
PDF
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
PPTX
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PPTX
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
PPTX
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
PPTX
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
PPTX
Precooling and Refrigerated storage.pptx
ThongamSunita
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
darshai cross section and river section analysis
muk7971
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
Comparison of Flexible and Rigid Pavements in Bangladesh
Arifur Rahman
 
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
Electrical_Safety_EMI_EMC_Presentation.pptx
drmaneharshalid
 
Artificial Intelligence jejeiejj3iriejrjifirirjdjeie
VikingsGaming2
 
LLC CM NCP1399 SIMPLIS MODEL MANUAL.PDF
ssuser1be9ce
 
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
Diabetes diabetes diabetes diabetes jsnsmxndm
130SaniyaAbduNasir
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Stability of IBR Dominated Grids - IEEE PEDG 2025 - short.pptx
ssuser307730
 
Unit_I Functional Units, Instruction Sets.pptx
logaprakash9
 
CM Function of the heart pp.pptxafsasdfddsf
drmaneharshalid
 
Precooling and Refrigerated storage.pptx
ThongamSunita
 

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”); } }