SlideShare une entreprise Scribd logo
1  sur  13
STACK
REPRESENTATION

BY- DIGVIJAY SINGH KARAKOTI
WHAT IS STACK?
Stack is the non-linear non-primitive data
structure or an ordered pair of elements.
A Stack is a LIFO structure which follows the
principal of “LAST IN FIRST OUT”, which
depicts the insertion of last element in the
stack and deletion of first element from the
stack from one end called “TOP” of the stack.
Some real life examples of
Stack
APPLICATIONS OF STACK
 Expression evaluation
 Infix, Prefix and Postfix Notation
 Expression conversion

 Memory Management
 Recursion
OPERATIONS PERFORMED IN
STACK
The m or oper at i ons per f or m by
aj
ed
st ack
ar e:
 PU ( ) – Thi s oper at i on i s used
SH
t o i nser t t he el em
ent i nt o t he
st ack. So, i t i s al so know as
n
“I N TI O ” oper at i on.
SER N
 PO ) - Thi s oper at i on i s used
P(
t o del et e or r et r i eve t he el em
ent
PUSH OPERATION
This function will add elements/items into
the stack. Whenever we add an element
into the stack the pointer TOP gets
incremented as:TOP+1 or TOP++
This is used to show the position of the
element in the stack.
PUSH operation on stack is to add values into the stack. Let us
assume that 5 items 30, 20, 25, 10 and 40 are to be placed on
the stack. The items can be inserted one by one as shown in
following figure:-
ALGORITHM FOR PUSH
OPERATIONITEM, TOP)
PUSH(MAXSTK,
STEP 1: If TOP = MAXSTK THEN [Stack already
filled?]
Print "OVERFLOW"
Go to step 4
End if
STEP 2: TOP = TOP + 1 [Increase TOP by 1]

STEP 3: Set STK[TOP] = ITEM [Insert ITEM in
new TOP position]
Program implementation of PUSH
operation
void push()
{ int item;
If(TOP==maxsize-1)
{ printf(“n Stack is full”);
getch();
exit(0);
}
else
{ printf(“n Enter the element to be inserted”);
scanf(“%d”, &item);
TOP=TOP+1;
stack[TOP]=item;
}
}
POP OPERATION
This function will delete elements/items
from the stack. Whenever we add an
element into the stack the pointer TOP
gets decremented as:TOP-1 or TOP-This is used to show the position of the
element in the stack
POP operation on stack is to delete or retrieve values from the
stack. Let us assume that 4 items 15, 12, 10 and 5 are to be
deleted from the stack. The items can be deleted one by one as
shown in following figure:-

Figure. Deletion operations
ALGORITHM FOR POP
OPERATION
POP[STACK,TOP,ITEM]
STEP 1: If TOP=0
Print ”Underflow”
STEP 2: Set ITEM=STACK[TOP]
STEP 3: Set TOP=TOP-1
STEP 4: Return
Program implementation of POP
operation
int pop()
{ int item;
if(TOP==-1)
{ printf(“n Stack is empty”);
getch();
exit(0);
}
else
{ item=stack[TOP];
TOP=TOP-1;
printf(“n Item deleted is= %d”, item);
}
return(item);
}

Contenu connexe

Tendances

Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureYaksh Jethva
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaDipayan Sarkar
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTSoumen Santra
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESSowmya Jyothi
 
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxApplication of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxPrakash Zodge
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListManishPrajapati78
 

Tendances (20)

Stack
StackStack
Stack
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
stack
stackstack
stack
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Application of Stack - Yadraj Meena
Application of Stack - Yadraj MeenaApplication of Stack - Yadraj Meena
Application of Stack - Yadraj Meena
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptxApplication of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Stack of Data structure
Stack of Data structureStack of Data structure
Stack of Data structure
 

En vedette

STAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash ReproductionSTAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash ReproductionSung Kim
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examplesgreatqadirgee4u
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleHitesh Kumar
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image RestorationMathankumar S
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
How To Write Effective Case Scenarios
How To Write Effective Case ScenariosHow To Write Effective Case Scenarios
How To Write Effective Case ScenariosJustina Sharma
 
Queue data structure
Queue data structureQueue data structure
Queue data structureanooppjoseph
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShareSlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShareSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

En vedette (11)

STAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash ReproductionSTAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash Reproduction
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
Queue in C, Queue Real Life of Example
Queue in C, Queue Real Life of ExampleQueue in C, Queue Real Life of Example
Queue in C, Queue Real Life of Example
 
Digital Image Processing - Image Restoration
Digital Image Processing - Image RestorationDigital Image Processing - Image Restoration
Digital Image Processing - Image Restoration
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
How To Write Effective Case Scenarios
How To Write Effective Case ScenariosHow To Write Effective Case Scenarios
How To Write Effective Case Scenarios
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Similaire à Data structure by Digvijay

Explain what does the following function do void foo (Stack s) { .pdf
Explain what does the following function do  void foo (Stack s)  {  .pdfExplain what does the following function do  void foo (Stack s)  {  .pdf
Explain what does the following function do void foo (Stack s) { .pdfmeerobertsonheyde608
 
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
 
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxStack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxShivam Kumar
 
Applicationofstack by Ali F.RAshid
Applicationofstack  by Ali F.RAshid Applicationofstack  by Ali F.RAshid
Applicationofstack by Ali F.RAshid ali rashid
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
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
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with exampleNamanKikani
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacksmaamir farooq
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfGirT2
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data StructureUshaP15
 

Similaire à Data structure by Digvijay (20)

Explain what does the following function do void foo (Stack s) { .pdf
Explain what does the following function do  void foo (Stack s)  {  .pdfExplain what does the following function do  void foo (Stack s)  {  .pdf
Explain what does the following function do void foo (Stack s) { .pdf
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
04 stacks
04 stacks04 stacks
04 stacks
 
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
 
Stack
StackStack
Stack
 
Stack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptxStack and its operation implemented with array new - Copy.pptx
Stack and its operation implemented with array new - Copy.pptx
 
Lect 15-16 Zaheer Abbas
Lect 15-16 Zaheer  AbbasLect 15-16 Zaheer  Abbas
Lect 15-16 Zaheer Abbas
 
Stack and its operations
Stack and its operationsStack and its operations
Stack and its operations
 
Applicationofstack by Ali F.RAshid
Applicationofstack  by Ali F.RAshid Applicationofstack  by Ali F.RAshid
Applicationofstack by Ali F.RAshid
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
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
 
Stack operation algorithms with example
Stack operation algorithms with exampleStack operation algorithms with example
Stack operation algorithms with example
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
DATA STRUCTURE - STACK
DATA STRUCTURE - STACKDATA STRUCTURE - STACK
DATA STRUCTURE - STACK
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Ds stacks
Ds stacksDs stacks
Ds stacks
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
 

Plus de Digvijay Singh Karakoti

Plus de Digvijay Singh Karakoti (8)

Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Computer Hardware Basics (Components to be understand)
Computer Hardware Basics (Components to be understand)Computer Hardware Basics (Components to be understand)
Computer Hardware Basics (Components to be understand)
 
Digital signature
Digital signatureDigital signature
Digital signature
 
Simon’s model for Decision Making Process
Simon’s model for Decision Making ProcessSimon’s model for Decision Making Process
Simon’s model for Decision Making Process
 
Operations Research-2nd edition
Operations Research-2nd editionOperations Research-2nd edition
Operations Research-2nd edition
 
Root Of The Equations [By- Digvijay]
Root Of The Equations [By- Digvijay]Root Of The Equations [By- Digvijay]
Root Of The Equations [By- Digvijay]
 
DMA presentation [By- Digvijay]
DMA presentation [By- Digvijay]DMA presentation [By- Digvijay]
DMA presentation [By- Digvijay]
 
General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]General OOP concept [by-Digvijay]
General OOP concept [by-Digvijay]
 

Dernier

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 

Dernier (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 

Data structure by Digvijay

  • 2. WHAT IS STACK? Stack is the non-linear non-primitive data structure or an ordered pair of elements. A Stack is a LIFO structure which follows the principal of “LAST IN FIRST OUT”, which depicts the insertion of last element in the stack and deletion of first element from the stack from one end called “TOP” of the stack.
  • 3. Some real life examples of Stack
  • 4. APPLICATIONS OF STACK  Expression evaluation  Infix, Prefix and Postfix Notation  Expression conversion  Memory Management  Recursion
  • 5. OPERATIONS PERFORMED IN STACK The m or oper at i ons per f or m by aj ed st ack ar e:  PU ( ) – Thi s oper at i on i s used SH t o i nser t t he el em ent i nt o t he st ack. So, i t i s al so know as n “I N TI O ” oper at i on. SER N  PO ) - Thi s oper at i on i s used P( t o del et e or r et r i eve t he el em ent
  • 6. PUSH OPERATION This function will add elements/items into the stack. Whenever we add an element into the stack the pointer TOP gets incremented as:TOP+1 or TOP++ This is used to show the position of the element in the stack.
  • 7. PUSH operation on stack is to add values into the stack. Let us assume that 5 items 30, 20, 25, 10 and 40 are to be placed on the stack. The items can be inserted one by one as shown in following figure:-
  • 8. ALGORITHM FOR PUSH OPERATIONITEM, TOP) PUSH(MAXSTK, STEP 1: If TOP = MAXSTK THEN [Stack already filled?] Print "OVERFLOW" Go to step 4 End if STEP 2: TOP = TOP + 1 [Increase TOP by 1] STEP 3: Set STK[TOP] = ITEM [Insert ITEM in new TOP position]
  • 9. Program implementation of PUSH operation void push() { int item; If(TOP==maxsize-1) { printf(“n Stack is full”); getch(); exit(0); } else { printf(“n Enter the element to be inserted”); scanf(“%d”, &item); TOP=TOP+1; stack[TOP]=item; } }
  • 10. POP OPERATION This function will delete elements/items from the stack. Whenever we add an element into the stack the pointer TOP gets decremented as:TOP-1 or TOP-This is used to show the position of the element in the stack
  • 11. POP operation on stack is to delete or retrieve values from the stack. Let us assume that 4 items 15, 12, 10 and 5 are to be deleted from the stack. The items can be deleted one by one as shown in following figure:- Figure. Deletion operations
  • 12. ALGORITHM FOR POP OPERATION POP[STACK,TOP,ITEM] STEP 1: If TOP=0 Print ”Underflow” STEP 2: Set ITEM=STACK[TOP] STEP 3: Set TOP=TOP-1 STEP 4: Return
  • 13. Program implementation of POP operation int pop() { int item; if(TOP==-1) { printf(“n Stack is empty”); getch(); exit(0); } else { item=stack[TOP]; TOP=TOP-1; printf(“n Item deleted is= %d”, item); } return(item); }