SlideShare a Scribd company logo
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptx
 Stack is a linear data structure which means the
data value are arranged in an orderly manner in single
path.
 Stack has one door which is responsible for insertion
and deletion of data from list.
 Stack follow special mechanism on the list that is
LIFO ( LAST IN FIRST OUT )
 In LIFO the data came in list lastly in the list will be out
firstly from the list.
Top is Special variable of stack which is use to
insert and delete the data value in the list. In
Top, Push() function is used to insert new
elements into stack and pop() function is used
to delete the element from the stack. Both
insertion and deletion are allowed at only one
end of Stack called Top.
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptx
Stack are basically three
operations that can be
performed on stack –
 Push
 Pop
 Peep
 push () – push operation is
used to insert the new data in
stack. If the stack is full, then it
is said to be an overflow
condition.
 pop () – Pop operation is
used to delete the data in
stack. If the stack is empty,
then it is said to be an
underflow condition.
 peep() - The peep
operation is used to display
all the data of the stack.
 int arr [5]; int top = -1;
 Insertion and deletion at the top of the stack
only.
 Initially when the stack is empty, top = -1
 For push operation, first the value of top is
increase by 1 and then the new element is
pushed at the position of top.
 For pop operation, first
the element at the
position of top is popped
and then top is decreased
by 1
 Push, check for
overflow.
 Pop, operation for
underflow.
#include <stdio.h>
#include <conio.h>
#define MAX 5
int a[MAX], top= -1;
void push ();
void pop ();
void disp();
int main();
{ int ch;
printf(“1. push or insertn”);
printf(“2. POP or Deleten”);
printf(“3. Displayn”);
printf(“4. End program”);
while(1)
{
printf(“n Enter Choice:”);
scanf(“%d”, &ch);
switch(ch)
{
case 1:
{
push ();
break;
}
case 2:
{
pop ();
break;
}
case 3:
{
display ();
break;
}
case 4:
{
exit (0);
}
default:
{
printf(“wrong choice”);
}
}
}
}
void push()
{
Int data;
If (top==MAX-1)
{
printf (“n Overflow or Stack is Full”);
}
else
{
prinf(“Enter Element to be pushed:”);
scanf (“%d”, &data);
top++;
a[top] =data;
}
}
void pop()
{
if (top==-1)
{
printf(“Underflow or Stack is Empty”);
}
else
{
printf(“Popped Element : &d”, a[top]);
top-- ;
}
}
void display ()
{
int i;
if (top >=0)
{
printf (“Elements:”);
for ( i=top; i>=0; i--)
printf (“n%d”, a[i]);
}
else
{
printf(“The STACK is EMPTY”);
}
}
Group Details
 Ravi Prakash-(Roll 05)
 Pritesh Kumar-(Roll 15)
 Ankit Kumar-(Roll 25)
 Aditya Raj-(Roll 35)
 Sakshi Gupta-(Roll 45)
 Vivek Kumar-(Roll 55)
Stack and its operation implemented with array new - Copy.pptx
Ad

More Related Content

Similar to Stack and its operation implemented with array new - Copy.pptx (20)

STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
rupam100
 
DSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUEDSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
Usha P
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
V.V.Vanniaperumal College for Women
 
Stack and its operations, Queue and its operations
Stack and its operations, Queue and its operationsStack and its operations, Queue and its operations
Stack and its operations, Queue and its operations
poongothai11
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
The presentation on stack data structure
The presentation on stack data structureThe presentation on stack data structure
The presentation on stack data structure
gaurav77712
 
04 stacks
04 stacks04 stacks
04 stacks
Rajan Gautam
 
Stack
StackStack
Stack
maamir farooq
 
Ds stacks
Ds stacksDs stacks
Ds stacks
GIGI JOSEPH
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
DS- Stack ADT
DS- Stack ADTDS- Stack ADT
DS- Stack ADT
MythiliMurugan3
 
Lecture5
Lecture5Lecture5
Lecture5
Muhammad Zubair
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
tristans3
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
Devyani Chaudhari
 
Stack push pop
Stack push popStack push pop
Stack push pop
A. S. M. Shafi
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptx
SonaPathak4
 
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
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
GirT2
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
rupam100
 
DSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUEDSA- Unit III- STACK AND QUEUE
DSA- Unit III- STACK AND QUEUE
swathirajstar
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
Usha P
 
Stack and its operations, Queue and its operations
Stack and its operations, Queue and its operationsStack and its operations, Queue and its operations
Stack and its operations, Queue and its operations
poongothai11
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 
The presentation on stack data structure
The presentation on stack data structureThe presentation on stack data structure
The presentation on stack data structure
gaurav77712
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
SIMONTHOMAS S
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
tristans3
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptx
SonaPathak4
 
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
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
GirT2
 

Recently uploaded (20)

Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Cyntexa
 
React Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for SuccessReact Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for Success
Amelia Swank
 
MEMS IC Substrate Technologies Guide 2025.pptx
MEMS IC Substrate Technologies Guide 2025.pptxMEMS IC Substrate Technologies Guide 2025.pptx
MEMS IC Substrate Technologies Guide 2025.pptx
IC substrate Shawn Wang
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Artificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptxArtificial_Intelligence_in_Everyday_Life.pptx
Artificial_Intelligence_in_Everyday_Life.pptx
03ANMOLCHAURASIYA
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Developing System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptxDeveloping System Infrastructure Design Plan.pptx
Developing System Infrastructure Design Plan.pptx
wondimagegndesta
 
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient CareAn Overview of Salesforce Health Cloud & How is it Transforming Patient Care
An Overview of Salesforce Health Cloud & How is it Transforming Patient Care
Cyntexa
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Why Slack Should Be Your Next Business Tool? (Tips to Make Most out of Slack)
Cyntexa
 
React Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for SuccessReact Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for Success
Amelia Swank
 
MEMS IC Substrate Technologies Guide 2025.pptx
MEMS IC Substrate Technologies Guide 2025.pptxMEMS IC Substrate Technologies Guide 2025.pptx
MEMS IC Substrate Technologies Guide 2025.pptx
IC substrate Shawn Wang
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Top-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptxTop-AI-Based-Tools-for-Game-Developers (1).pptx
Top-AI-Based-Tools-for-Game-Developers (1).pptx
BR Softech
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Ad

Stack and its operation implemented with array new - Copy.pptx

  • 3.  Stack is a linear data structure which means the data value are arranged in an orderly manner in single path.  Stack has one door which is responsible for insertion and deletion of data from list.  Stack follow special mechanism on the list that is LIFO ( LAST IN FIRST OUT )
  • 4.  In LIFO the data came in list lastly in the list will be out firstly from the list.
  • 5. Top is Special variable of stack which is use to insert and delete the data value in the list. In Top, Push() function is used to insert new elements into stack and pop() function is used to delete the element from the stack. Both insertion and deletion are allowed at only one end of Stack called Top.
  • 8. Stack are basically three operations that can be performed on stack –  Push  Pop  Peep
  • 9.  push () – push operation is used to insert the new data in stack. If the stack is full, then it is said to be an overflow condition.
  • 10.  pop () – Pop operation is used to delete the data in stack. If the stack is empty, then it is said to be an underflow condition.
  • 11.  peep() - The peep operation is used to display all the data of the stack.
  • 12.  int arr [5]; int top = -1;  Insertion and deletion at the top of the stack only.  Initially when the stack is empty, top = -1  For push operation, first the value of top is increase by 1 and then the new element is pushed at the position of top.
  • 13.  For pop operation, first the element at the position of top is popped and then top is decreased by 1  Push, check for overflow.  Pop, operation for underflow.
  • 14. #include <stdio.h> #include <conio.h> #define MAX 5 int a[MAX], top= -1; void push (); void pop (); void disp(); int main(); { int ch; printf(“1. push or insertn”);
  • 15. printf(“2. POP or Deleten”); printf(“3. Displayn”); printf(“4. End program”); while(1) { printf(“n Enter Choice:”); scanf(“%d”, &ch); switch(ch) { case 1: { push (); break; }
  • 16. case 2: { pop (); break; } case 3: { display (); break; } case 4: { exit (0); } default: { printf(“wrong choice”); } } } }
  • 17. void push() { Int data; If (top==MAX-1) { printf (“n Overflow or Stack is Full”); } else { prinf(“Enter Element to be pushed:”); scanf (“%d”, &data); top++; a[top] =data; } }
  • 18. void pop() { if (top==-1) { printf(“Underflow or Stack is Empty”); } else { printf(“Popped Element : &d”, a[top]); top-- ; } } void display () { int i;
  • 19. if (top >=0) { printf (“Elements:”); for ( i=top; i>=0; i--) printf (“n%d”, a[i]); } else { printf(“The STACK is EMPTY”); } }
  • 20. Group Details  Ravi Prakash-(Roll 05)  Pritesh Kumar-(Roll 15)  Ankit Kumar-(Roll 25)  Aditya Raj-(Roll 35)  Sakshi Gupta-(Roll 45)  Vivek Kumar-(Roll 55)
  翻译: