SlideShare a Scribd company logo
 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

trees in data structure
trees in data structure trees in data structure
trees in data structure
shameen khan
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
Pankaj Thakur
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
RacksaviR
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms I
Mohamed Loey
 
Tree
TreeTree
Tree
bhumish
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
stack presentation
stack presentationstack presentation
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
Dharita Chokshi
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
Anand Ingle
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Heap and heapsort
Heap and heapsortHeap and heapsort
Heap and heapsort
Amit Kumar Rathi
 
Binary Search Tree
Binary Search TreeBinary Search Tree

What's hot (20)

trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
Prim's algorithm
Prim's algorithmPrim's algorithm
Prim's algorithm
 
Heaps
HeapsHeaps
Heaps
 
Linked list
Linked listLinked list
Linked list
 
stack & queue
stack & queuestack & queue
stack & queue
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Algorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms IAlgorithms Lecture 4: Sorting Algorithms I
Algorithms Lecture 4: Sorting Algorithms I
 
Tree
TreeTree
Tree
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
stack presentation
stack presentationstack presentation
stack presentation
 
Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)Presentation on Breadth First Search (BFS)
Presentation on Breadth First Search (BFS)
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 
single linked list
single linked listsingle linked list
single linked list
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Heap and heapsort
Heap and heapsortHeap and heapsort
Heap and heapsort
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 

Viewers also liked

DS_Final_Project
DS_Final_ProjectDS_Final_Project
DS_Final_Project星星 孫
 
Library management in Data structure
Library management in Data structure Library management in Data structure
Library management in Data structure
harshil1902
 
Garrage management system
Garrage management system Garrage management system
Garrage management system
Prateek Pandey
 
Calendar c
Calendar cCalendar c
Calendar c
Shanellebyrd
 
Simple Calendar Application using C
Simple Calendar Application using CSimple Calendar Application using C
Simple Calendar Application using C
codewithc
 
62 how to track someone elses line messages
62 how to track someone elses line messages62 how to track someone elses line messages
62 how to track someone elses line messagesCatherineRai
 
Costume analysis
Costume analysisCostume analysis
Costume analysis
HannahO4997
 
آشنایی با زیرساخت کلید عمومی (PKI)
آشنایی با زیرساخت کلید عمومی (PKI)آشنایی با زیرساخت کلید عمومی (PKI)
آشنایی با زیرساخت کلید عمومی (PKI)
مرکز دولتی صدور گواهی الکترونیکی ریشه
 
how to spy on husbands line messages
how to spy on husbands line messageshow to spy on husbands line messages
how to spy on husbands line messages
CatherineRai
 
งานนำเสนชุมชน (แก้ไข)
งานนำเสนชุมชน (แก้ไข)งานนำเสนชุมชน (แก้ไข)
งานนำเสนชุมชน (แก้ไข)
Blsaw Wannarat
 
Biochemistry
BiochemistryBiochemistry
Biochemistryqalikn
 
Algo labpresentation a_group
Algo labpresentation a_groupAlgo labpresentation a_group
Algo labpresentation a_group
Umme habiba
 
Erick hernandez
Erick hernandezErick hernandez
Erick hernandez
ErickHernandez1020
 
how to hack my husbands LINE
how to hack my husbands LINE how to hack my husbands LINE
how to hack my husbands LINE
CatherineRai
 
how to track line chat remotely
how to track line chat remotelyhow to track line chat remotely
how to track line chat remotely
CatherineRai
 
how to spy on LINE chat history
how to spy on LINE chat history how to spy on LINE chat history
how to spy on LINE chat history
CatherineRai
 
how to spy on LINE messages
how to spy on LINE messageshow to spy on LINE messages
how to spy on LINE messages
CatherineRai
 

Viewers also liked (19)

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

Similar to Project of data structure

Stack
StackStack
04 stacks
04 stacks04 stacks
04 stacks
Rajan Gautam
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
Ahsan Mansiv
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
RAtna29
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
SajalFayyaz
 
Stack data structure
Stack data structureStack data structure
Stack data structure
rogineojerio020496
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
AliRaza899305
 
Stacks
StacksStacks
Stacks
Sadaf Ismail
 
STACK1.pptx
STACK1.pptxSTACK1.pptx
STACK1.pptx
MouDhara1
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
MO 2020 DS Stacks 1 AB.ppt
MO 2020 DS Stacks 1 AB.pptMO 2020 DS Stacks 1 AB.ppt
MO 2020 DS Stacks 1 AB.ppt
shashankbhadouria4
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Stack
StackStack
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with example
NamanKikani
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx
ajoy21
 
13 Stacks and Queues.pptx
13 Stacks and Queues.pptx13 Stacks and Queues.pptx
13 Stacks and Queues.pptx
ssuserb7c8b8
 

Similar to Project of data structure (20)

Stack
StackStack
Stack
 
04 stacks
04 stacks04 stacks
04 stacks
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Stacks
StacksStacks
Stacks
 
STACK1.pptx
STACK1.pptxSTACK1.pptx
STACK1.pptx
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
MO 2020 DS Stacks 1 AB.ppt
MO 2020 DS Stacks 1 AB.pptMO 2020 DS Stacks 1 AB.ppt
MO 2020 DS Stacks 1 AB.ppt
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stack
StackStack
Stack
 
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with example
 
#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx#C programming Question 35Implement the functions required for the.docx
#C programming Question 35Implement the functions required for the.docx
 
13 Stacks and Queues.pptx
13 Stacks and Queues.pptx13 Stacks and Queues.pptx
13 Stacks and Queues.pptx
 
Stacks
StacksStacks
Stacks
 

More from Umme habiba

Compiler lab final report writing
Compiler lab final report writingCompiler lab final report writing
Compiler lab final report writing
Umme habiba
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
Umme habiba
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
Umme habiba
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
Umme habiba
 
Accounting adjusting
Accounting adjustingAccounting adjusting
Accounting adjusting
Umme habiba
 
Economic.assignment
Economic.assignmentEconomic.assignment
Economic.assignment
Umme habiba
 
Major economic problems of bangladesh
Major economic problems of bangladeshMajor economic problems of bangladesh
Major economic problems of bangladesh
Umme habiba
 
Overview of various types of operating system
Overview of various types of operating systemOverview of various types of operating system
Overview of various types of operating system
Umme habiba
 
Os lab report(shell coding)
Os lab report(shell coding)Os lab report(shell coding)
Os lab report(shell coding)
Umme habiba
 
Ecommerce(online Shopping)
Ecommerce(online Shopping)Ecommerce(online Shopping)
Ecommerce(online Shopping)
Umme habiba
 
Different types of Addressing.cao
Different types of Addressing.caoDifferent types of Addressing.cao
Different types of Addressing.cao
Umme habiba
 
2nd generation of computer
2nd generation of computer2nd generation of computer
2nd generation of computer
Umme habiba
 
Art_of_living assignment
Art_of_living assignmentArt_of_living assignment
Art_of_living assignment
Umme habiba
 
Art_of_living
Art_of_livingArt_of_living
Art_of_living
Umme habiba
 
Informationsecurity
InformationsecurityInformationsecurity
Informationsecurity
Umme habiba
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
Umme habiba
 
WLAN of networking.ppt
WLAN of networking.pptWLAN of networking.ppt
WLAN of networking.ppt
Umme habiba
 
simpson's in numerical method
simpson's in numerical methodsimpson's in numerical method
simpson's in numerical method
Umme habiba
 
Error detection in Data comunication
 Error detection in Data comunication Error detection in Data comunication
Error detection in Data comunication
Umme habiba
 
microsoft word & powerpoint
 microsoft word & powerpoint microsoft word & powerpoint
microsoft word & powerpoint
Umme habiba
 

More from Umme habiba (20)

Compiler lab final report writing
Compiler lab final report writingCompiler lab final report writing
Compiler lab final report writing
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
 
online bus ticket booking system
online bus ticket booking systemonline bus ticket booking system
online bus ticket booking system
 
Accounting adjusting
Accounting adjustingAccounting adjusting
Accounting adjusting
 
Economic.assignment
Economic.assignmentEconomic.assignment
Economic.assignment
 
Major economic problems of bangladesh
Major economic problems of bangladeshMajor economic problems of bangladesh
Major economic problems of bangladesh
 
Overview of various types of operating system
Overview of various types of operating systemOverview of various types of operating system
Overview of various types of operating system
 
Os lab report(shell coding)
Os lab report(shell coding)Os lab report(shell coding)
Os lab report(shell coding)
 
Ecommerce(online Shopping)
Ecommerce(online Shopping)Ecommerce(online Shopping)
Ecommerce(online Shopping)
 
Different types of Addressing.cao
Different types of Addressing.caoDifferent types of Addressing.cao
Different types of Addressing.cao
 
2nd generation of computer
2nd generation of computer2nd generation of computer
2nd generation of computer
 
Art_of_living assignment
Art_of_living assignmentArt_of_living assignment
Art_of_living assignment
 
Art_of_living
Art_of_livingArt_of_living
Art_of_living
 
Informationsecurity
InformationsecurityInformationsecurity
Informationsecurity
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
 
WLAN of networking.ppt
WLAN of networking.pptWLAN of networking.ppt
WLAN of networking.ppt
 
simpson's in numerical method
simpson's in numerical methodsimpson's in numerical method
simpson's in numerical method
 
Error detection in Data comunication
 Error detection in Data comunication Error detection in Data comunication
Error detection in Data comunication
 
microsoft word & powerpoint
 microsoft word & powerpoint microsoft word & powerpoint
microsoft word & powerpoint
 

Recently uploaded

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 

Recently uploaded (20)

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 

Project of data structure

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