SlideShare a Scribd company logo
4
Most read
6
Most read
13
Most read
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);
}

More Related Content

What's hot (20)

PPTX
Application of Stack - Yadraj Meena
Dipayan Sarkar
 
PPT
Stacks
Malainine Zaid
 
PPTX
STACKS IN DATASTRUCTURE
Archie Jamwal
 
PPSX
Stacks Implementation and Examples
greatqadirgee4u
 
PPTX
Queues
Ashim Lamichhane
 
PPSX
Data Structure (Queue)
Adam Mukharil Bachtiar
 
PPTX
Stack - Data Structure
Bhavesh Sanghvi
 
PPTX
Linked List
RaaviKapoor
 
PPTX
Stack and its operations
V.V.Vanniaperumal College for Women
 
PPT
Stack a Data Structure
ForwardBlog Enewzletter
 
PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PDF
Stack
Zaid Shabbir
 
PPTX
Linked list
akshat360
 
PPT
Queue data structure
anooppjoseph
 
PDF
sparse matrix in data structure
MAHALAKSHMI P
 
PPTX
LL(1) parsing
KHYATI PATEL
 
PPTX
Linked List
Ashim Lamichhane
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
PPTX
Stack data structure
Tech_MX
 
Application of Stack - Yadraj Meena
Dipayan Sarkar
 
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Stacks Implementation and Examples
greatqadirgee4u
 
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Stack - Data Structure
Bhavesh Sanghvi
 
Linked List
RaaviKapoor
 
Stack and its operations
V.V.Vanniaperumal College for Women
 
Stack a Data Structure
ForwardBlog Enewzletter
 
Priority Queue in Data Structure
Meghaj Mallick
 
Linked list
akshat360
 
Queue data structure
anooppjoseph
 
sparse matrix in data structure
MAHALAKSHMI P
 
LL(1) parsing
KHYATI PATEL
 
Linked List
Ashim Lamichhane
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Stack data structure
Tech_MX
 

Viewers also liked (10)

PPTX
STAR: Stack Trace based Automatic Crash Reproduction
Sung Kim
 
PPTX
U3.stack queue
Ssankett Negi
 
PDF
Queue in C, Queue Real Life of Example
Hitesh Kumar
 
PDF
Digital Image Processing - Image Restoration
Mathankumar S
 
PPT
Stack Data Structure & It's Application
Tech_MX
 
PPT
Queue Data Structure
Zidny Nafan
 
PPTX
How To Write Effective Case Scenarios
Justina Sharma
 
PDF
2015 Upload Campaigns Calendar - SlideShare
SlideShare
 
PPTX
What to Upload to SlideShare
SlideShare
 
PDF
Getting Started With SlideShare
SlideShare
 
STAR: Stack Trace based Automatic Crash Reproduction
Sung Kim
 
U3.stack queue
Ssankett Negi
 
Queue in C, Queue Real Life of Example
Hitesh Kumar
 
Digital Image Processing - Image Restoration
Mathankumar S
 
Stack Data Structure & It's Application
Tech_MX
 
Queue Data Structure
Zidny Nafan
 
How To Write Effective Case Scenarios
Justina Sharma
 
2015 Upload Campaigns Calendar - SlideShare
SlideShare
 
What to Upload to SlideShare
SlideShare
 
Getting Started With SlideShare
SlideShare
 
Ad

Similar to Data structure by Digvijay (20)

PDF
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
PPTX
Data structure Stack
Praveen Vishwakarma
 
PDF
Stack
Amrutha Rajan
 
PPT
Lect 15-16 Zaheer Abbas
Information Technology Center
 
PDF
The Stack (Data Structccccccccccccccccccc
parwarsmko98
 
PDF
04 stacks
Rajan Gautam
 
PPTX
STACK.pptx
rupam100
 
PDF
Data structure.pdf
piyushagarwal279293
 
PPTX
stack_ppt_DSA(sudipta samanta).pptx push,pop,peek operation
sudiptasamanta86493
 
PPTX
Stack in C.pptx
RituSarkar7
 
PPT
stack, opeartions on stack, applications of stack
Minakshee Patil
 
PDF
Stack
maamir farooq
 
PDF
Stack push pop
A. S. M. Shafi
 
PPTX
Data Structure ARRAY REPRESENTATION OF STACKS
Anil Yadav
 
PPTX
Unit 3 stack
Dabbal Singh Mahara
 
PPTX
Data Structure.pptx
SajalFayyaz
 
PPTX
Stacks and queues using aaray line .pptx
ramkumar649780
 
PPTX
Stack PPT.pptx
UzmaRizvi5
 
PDF
Stacks
amitphadikar2012
 
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
Data structure Stack
Praveen Vishwakarma
 
Lect 15-16 Zaheer Abbas
Information Technology Center
 
The Stack (Data Structccccccccccccccccccc
parwarsmko98
 
04 stacks
Rajan Gautam
 
STACK.pptx
rupam100
 
Data structure.pdf
piyushagarwal279293
 
stack_ppt_DSA(sudipta samanta).pptx push,pop,peek operation
sudiptasamanta86493
 
Stack in C.pptx
RituSarkar7
 
stack, opeartions on stack, applications of stack
Minakshee Patil
 
Stack push pop
A. S. M. Shafi
 
Data Structure ARRAY REPRESENTATION OF STACKS
Anil Yadav
 
Unit 3 stack
Dabbal Singh Mahara
 
Data Structure.pptx
SajalFayyaz
 
Stacks and queues using aaray line .pptx
ramkumar649780
 
Stack PPT.pptx
UzmaRizvi5
 
6 - STACKS in Data Structure and Algorithm.pptx
RahulRaj493025
 
Ad

More from Digvijay Singh Karakoti (8)

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

Recently uploaded (20)

PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
community health nursing question paper 2.pdf
Prince kumar
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 

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); }