SlideShare a Scribd company logo
Submitted By:
Sheikh Monirul
Hasan
ID: 162015077
Department: CSE
Submitted To:
Lecturer : Department of CSE
Green University of Bangladesh
Green University of Bangladesh
1
Welcome
to
Our Presentation
2
Stack
3
1.What is Stack
Stack Operation
1.A LIFO Satack
4.Push Operation
5.Pop Operation
6.Stack Program
.Program Output
4
A stack is a Last In, First Out (LIFO) data structure,objects
inserted last are the first to come out of the stack
Anything added to the stack goes on the “top” of the stack
Anything removed from the stack is taken from the “top” of the
stack
Things are removed in the reverse order from that in which they
were inserted
5
PUSH
Adds the object to the top of the stack
POP
Removes the object at the top of the stack and returns it
PEEK
Returns the top object of the stack but does not remove it from the
stack
ISEMPTY
Returns True if Stack is empty
6
Top
Bottom
Stack Pointer
Push Pop
7
8
9
#include <stdio.h>
#define MAXSIZE 5
struct stack
{
int stk[MAXSIZE];
int top;
};
typedef struct stack STACK;
STACK s;
void push(void);
int pop(void);
void display(void);
void main ()
{
int choice;
int option = 1;
s.top = -1;
printf ("STACK OPERATIONn");
while (option)
{
printf ("------------------------------------------n");
printf (" 1 --> PUSH n");
printf (" 2 --> POP n");
printf (" 3 --> DISPLAY n");
printf (" 4 --> EXIT n");
printf ("------------------------------------------n");
printf ("Enter your choicen");
scanf ("%d", &choice);
switch (choice)
10
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
display();
break;
case 4:
return;
}
fflush (stdin);
printf ("Do you want to continue(Type 0 or 1)?n");
scanf ("%d", &option);
}
}
/* Function to add an element to the stack */
void push ()
{
int num;
if (s.top == (MAXSIZE - 1))
{
printf ("Stack is Fulln");
return;
}
else
{
printf ("Enter the element to be pushedn");
scanf ("%d", &num);
s.top = s.top + 1;
s.stk[s.top] = num;
}
return;
} 11
int pop ()
{
int num;
if (s.top == - 1)
{
printf ("Stack is Emptyn");
return (s.top);
}
else
{
num = s.stk[s.top];
printf ("poped element is = %dn", s.stk[s.top]);
s.top = s.top - 1;
}
return(num);
}
/* Function to display the status of the stack */
void display ()
{
int i;
if (s.top == -1)
{
printf ("Stack is emptyn");
return;
}
else
{
printf ("n The status of the stack is n");
for (i = s.top; i >= 0; i--)
{
printf ("%dn", s.stk[i]);
}
}
printf ("n");
return 0;
} 12
13
14
15
Have you any Question ?
16
Thank You

More Related Content

What's hot (20)

PPTX
Unit 4 queue
Dabbal Singh Mahara
 
PPTX
Queue Implementation Using Array & Linked List
PTCL
 
PPTX
Insertion sort
MYER301
 
PPT
Stacks
Malainine Zaid
 
PPSX
Stacks Implementation and Examples
greatqadirgee4u
 
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
PPTX
Introduction to stack
vaibhav2910
 
PPTX
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
PPTX
Stack and its Applications : Data Structures ADT
Soumen Santra
 
PDF
Applications of stack
eShikshak
 
PPTX
Stack using Array
Sayantan Sur
 
PPT
Stack a Data Structure
ForwardBlog Enewzletter
 
PPTX
Data structure by Digvijay
Digvijay Singh Karakoti
 
PPT
Stack
srihariyenduri
 
PPTX
Queues
Ashim Lamichhane
 
PPT
Queue Data Structure
Lovely Professional University
 
PPTX
Conversion of Infix to Prefix and Postfix with Stack
sahil kumar
 
PDF
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
PPTX
Stack operation algorithms with example
NamanKikani
 
PPTX
Infix-Postfix expression conversion
Rashmiranja625
 
Unit 4 queue
Dabbal Singh Mahara
 
Queue Implementation Using Array & Linked List
PTCL
 
Insertion sort
MYER301
 
Stacks Implementation and Examples
greatqadirgee4u
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Muhammad Hammad Waseem
 
Introduction to stack
vaibhav2910
 
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Stack and its Applications : Data Structures ADT
Soumen Santra
 
Applications of stack
eShikshak
 
Stack using Array
Sayantan Sur
 
Stack a Data Structure
ForwardBlog Enewzletter
 
Data structure by Digvijay
Digvijay Singh Karakoti
 
Queue Data Structure
Lovely Professional University
 
Conversion of Infix to Prefix and Postfix with Stack
sahil kumar
 
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
Stack operation algorithms with example
NamanKikani
 
Infix-Postfix expression conversion
Rashmiranja625
 

Similar to Stack of Data structure (20)

PPTX
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
PPTX
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
PPTX
DS- Stack ADT
MythiliMurugan3
 
PDF
Chapter 4 stack
jadhav_priti
 
DOCX
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
PPTX
Stacks in Data Structure
Lovely Professional University
 
PDF
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
PPTX
Stack and Queue.pptx university exam preparation
RAtna29
 
PDF
04 stacks
Rajan Gautam
 
PPTX
Stack and its operation implemented with array new - Copy.pptx
Shivam Kumar
 
PDF
Stack
maamir farooq
 
PPT
MO 2020 DS Stacks 1 AB.ppt
shashankbhadouria4
 
DOCX
Ds
Acad
 
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
PPTX
Stack PPT.pptx
UzmaRizvi5
 
PDF
Stack push pop
A. S. M. Shafi
 
PPT
data structure, stack, stack data structure
pcnmtutorials
 
PPTX
STACK.pptx
rupam100
 
PPTX
Data Structure.pptx
SajalFayyaz
 
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
DS- Stack ADT
MythiliMurugan3
 
Chapter 4 stack
jadhav_priti
 
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
Stacks in Data Structure
Lovely Professional University
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
Stack and Queue.pptx university exam preparation
RAtna29
 
04 stacks
Rajan Gautam
 
Stack and its operation implemented with array new - Copy.pptx
Shivam Kumar
 
MO 2020 DS Stacks 1 AB.ppt
shashankbhadouria4
 
Ds
Acad
 
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
Stack PPT.pptx
UzmaRizvi5
 
Stack push pop
A. S. M. Shafi
 
data structure, stack, stack data structure
pcnmtutorials
 
STACK.pptx
rupam100
 
Data Structure.pptx
SajalFayyaz
 
Ad

Recently uploaded (20)

PPTX
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Configure Re-Ordering From Portal in Odoo 18 Website
Celine George
 
Controller Request and Response in Odoo18
Celine George
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Introduction presentation of the patentbutler tool
MIPLM
 
Horarios de distribución de agua en julio
pegazohn1978
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
Introduction to Indian Writing in English
Trushali Dodiya
 
epi editorial commitee meeting presentation
MIPLM
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
infertility, types,causes, impact, and management
Ritu480198
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Ad

Stack of Data structure

  • 1. Submitted By: Sheikh Monirul Hasan ID: 162015077 Department: CSE Submitted To: Lecturer : Department of CSE Green University of Bangladesh Green University of Bangladesh 1
  • 4. 1.What is Stack Stack Operation 1.A LIFO Satack 4.Push Operation 5.Pop Operation 6.Stack Program .Program Output 4
  • 5. A stack is a Last In, First Out (LIFO) data structure,objects inserted last are the first to come out of the stack Anything added to the stack goes on the “top” of the stack Anything removed from the stack is taken from the “top” of the stack Things are removed in the reverse order from that in which they were inserted 5
  • 6. PUSH Adds the object to the top of the stack POP Removes the object at the top of the stack and returns it PEEK Returns the top object of the stack but does not remove it from the stack ISEMPTY Returns True if Stack is empty 6
  • 8. 8
  • 9. 9
  • 10. #include <stdio.h> #define MAXSIZE 5 struct stack { int stk[MAXSIZE]; int top; }; typedef struct stack STACK; STACK s; void push(void); int pop(void); void display(void); void main () { int choice; int option = 1; s.top = -1; printf ("STACK OPERATIONn"); while (option) { printf ("------------------------------------------n"); printf (" 1 --> PUSH n"); printf (" 2 --> POP n"); printf (" 3 --> DISPLAY n"); printf (" 4 --> EXIT n"); printf ("------------------------------------------n"); printf ("Enter your choicen"); scanf ("%d", &choice); switch (choice) 10
  • 11. { case 1: push(); break; case 2: pop(); break; case 3: display(); break; case 4: return; } fflush (stdin); printf ("Do you want to continue(Type 0 or 1)?n"); scanf ("%d", &option); } } /* Function to add an element to the stack */ void push () { int num; if (s.top == (MAXSIZE - 1)) { printf ("Stack is Fulln"); return; } else { printf ("Enter the element to be pushedn"); scanf ("%d", &num); s.top = s.top + 1; s.stk[s.top] = num; } return; } 11
  • 12. int pop () { int num; if (s.top == - 1) { printf ("Stack is Emptyn"); return (s.top); } else { num = s.stk[s.top]; printf ("poped element is = %dn", s.stk[s.top]); s.top = s.top - 1; } return(num); } /* Function to display the status of the stack */ void display () { int i; if (s.top == -1) { printf ("Stack is emptyn"); return; } else { printf ("n The status of the stack is n"); for (i = s.top; i >= 0; i--) { printf ("%dn", s.stk[i]); } } printf ("n"); return 0; } 12
  • 13. 13
  • 14. 14
  • 15. 15 Have you any Question ?