SlideShare a Scribd company logo
1 of 21
 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 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

More Related Content

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

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 QueueBalwant Gorad
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2SIMONTHOMAS 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.docxtristans3
 
Stack organization
Stack organizationStack organization
Stack organizationchauhankapil
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptxSonaPathak4
 
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 preparationRAtna29
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfGirT2
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdfTobyWtf
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxprakashvs7
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 

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

Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
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
 
04 stacks
04 stacks04 stacks
04 stacks
 
Stack
StackStack
Stack
 
Ds stacks
Ds stacksDs stacks
Ds stacks
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
 
DS- Stack ADT
DS- Stack ADTDS- Stack ADT
DS- Stack ADT
 
Lecture5
Lecture5Lecture5
Lecture5
 
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
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
 
Stack push pop
Stack push popStack push pop
Stack push pop
 
Stack organization
Stack organizationStack organization
Stack organization
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptx
 
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
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdf
 
DS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptxDS-UNIT 3 FINAL.pptx
DS-UNIT 3 FINAL.pptx
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stack
StackStack
Stack
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

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

  • 1.
  • 2.
  • 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.
  • 6.
  • 7.
  • 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)