SlideShare a Scribd company logo
Stack Data Structure By : Imam M Shofi
What is stack? A stack is a limited version of an array.  New elements, or nodes as they are often called, can be added to a stack and removed from a stack only from one end.  Access system a stack is referred to as a LIFO structure (Last-In First-Out) Some illustrations: stack of satay stack of CDs
Stacks operations Push : adds a new node Push(X,S)    add the value X to the TOP of stack Pop : removes a node Pop(S)    removes the TOP node and returns its value IsEmpty : reports whether the stack is empty IsEmpty(S)    report whether the stack S is empty IsFull : reports whether the stack is full IsFull(S)    report whether the stack S is full  Initialize : creates/initializes the stack Initialize(S)    create a new empty stack named S Destroy : deletes the contents of the stack (may be implemented by re-initializing the stack) Destroy(S)    deletes the contents of the stack S
Illustration/example Operation Stack’s contents TOP value 1. Initialiaze(S) <empty> 0 2. Push(‘a’,S) a 1 3. Push(‘b’,S) a b 2 4. Push(‘c’,S) a b c 3 5. Pop(S) a b 2 6. Push(‘d’,S) a b d 3 7. Push(‘e’,S) a b d e 4 8. Pop(S) a b d 3 9. Pop(S) a b 2 10. Pop(S) a 1
Exercise What would the state of the stack be after the following operations: create stack push A onto stack push F onto stack pop item from stack push B onto stack pop item from stack pop item from stack Show the state of the stack and the value of each variable after execution of each of the following statements: A = 5 B = 3 C = 7 (a) create stack push A onto stack push C*C onto stack pop item from stack and store in B push B+A onto stack pop item from stack and store in A pop item from stack and store in B (b) create stack push B onto stack push C onto stack push A onto stack A=B*C push A+C onto stack pop item from stack and store in A pop item from stack and store in B pop item from stack and store in C
Converting between notations INFIX to PREFIX : (A+B) – (C*D) Do the first brace: (A+B), the PREFIX is +AB Do the second brace: (C*D), the PREFIX is *CD The end is operator -:  +AB  -  *CD ,  the PREFIX is -+AB*CD INFIX to POSTFIX : (A+B) – (C*D) Do the first brace: (A+B), the POSTFIX is AB+ Do the second brace: (C*D), the POSTFIX is CD* The end is operator -:  AB+  -  CD* ,  the PREFIX is AB+CD*- PREFIX to INFIX : +/*A B C D Find the first operator: *, take 2 operands before the operator ( A  and  B ), the INFIX is (A*B) Find the second operator: /, take 2 operands before the operator ( A*B  and  C ), the INFIX is ((A*B)/C) Find the third operator: +, take 2 operands before the operator ( ((A*B)/C)  and  D ), the INFIX is ((A*B)/C)+D
Converting between notations(2) PREFIX to POSTFIX : +/*A B C D Find the first operator: *, take 2 operands before the operator ( A  and  B ), the POSTFIX is AB* Find the second operator: /, take 2 operands before the operator ( AB*  and  C ), the POSTFIX is AB*C/ Find the third operator: +, take 2 operands before the operator ( AB*C/  and  D ), the POSTFIX is AB*C/D+ POSTFIX to INFIX : ABCD*/- Find the first operator: *, take 2 operands before the operator ( C  and  D ), the INFIX is (C*D) Find the second operator: /, take 2 operands before the operator ( (C*D)  and  B ), the INFIX is (B/(C*D) Find the third operator: -, take 2 operands before the operator ( (B/(C*D)  and  A ), the INFIX is A – (B/(C*D) POSTFIX to PREFIX : ABCD*/- Find the first operator: *, take 2 operands before the operator ( C  and  D ), the PREFIX is *CD Find the second operator: /, take 2 operands before the operator ( *CD  and  B ), the PREFIX is /B*CD Find the third operator: -, take 2 operands before the operator ( /B*CD  and  A ), the PREFIX is -A /B*CD
Exercise: Converting Convert these INFIX to PREFIX and POSTFIX : A / B – C / D (A + B) ^ 3 – C * D A ^ (B + C) Convert these PREFIX to INFIX and POSTFIX : + – / A B C ^ D E –  + D E / X Y ^ + 2 3 – C D Convert these POSTFIX to INFIX and PREFIX : A B C + –  G H + I J / * A B ^ C D + –
Ad

More Related Content

What's hot (20)

STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
Archie Jamwal
 
Stacks
StacksStacks
Stacks
sweta dargad
 
Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions Conversion of Infix To Postfix Expressions
Conversion of Infix To Postfix Expressions
Kulachi Hansraj Model School Ashok Vihar
 
Stacks
StacksStacks
Stacks
sardorbek mamazhanov
 
Stack
StackStack
Stack
Ghaffar Khan
 
Stacks
StacksStacks
Stacks
Malainine Zaid
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
Mandeep Singh
 
stack presentation
stack presentationstack presentation
stack presentation
Shivalik college of engineering
 
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
Soumen Santra
 
Stack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptxStack_Application_Infix_Prefix.pptx
Stack_Application_Infix_Prefix.pptx
sandeep54552
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
greatqadirgee4u
 
Stacks in c++
Stacks in c++Stacks in c++
Stacks in c++
Vineeta Garg
 
Application of Stacks
Application of StacksApplication of Stacks
Application of Stacks
Ain-ul-Moiz Khawaja
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
Umme habiba
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
Dabbal Singh Mahara
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
Praveen Vishwakarma
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
Yaksh Jethva
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
Digvijay Singh Karakoti
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
Lovely Professional University
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
vaibhav2910
 

Viewers also liked (20)

Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
Adam Mukharil Bachtiar
 
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
B Liyanage Asanka
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
ForwardBlog Enewzletter
 
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
 
Stack Applications
Stack ApplicationsStack Applications
Stack Applications
Kulachi Hansraj Model School Ashok Vihar
 
Stacks
StacksStacks
Stacks
Temperory mukesh
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
Stack Data Structre Introduction and source code
Stack Data Structre Introduction and source codeStack Data Structre Introduction and source code
Stack Data Structre Introduction and source code
SL Coder
 
Algoritma dan Pemrograman C++ (Percabangan)
Algoritma dan Pemrograman C++ (Percabangan)Algoritma dan Pemrograman C++ (Percabangan)
Algoritma dan Pemrograman C++ (Percabangan)
Nabil Muhammad Firdaus
 
It 405 materi 2 java dasar
It 405 materi 2   java dasarIt 405 materi 2   java dasar
It 405 materi 2 java dasar
Ayi Purbasari
 
Viisio based rich picture version 2.0
Viisio based rich picture version 2.0Viisio based rich picture version 2.0
Viisio based rich picture version 2.0
Mithun112
 
Career Hub Rich Picture
Career Hub Rich PictureCareer Hub Rich Picture
Career Hub Rich Picture
guestc990b6
 
MeTA MSP workshop: Issues and challenges: Rich picture
MeTA MSP workshop: Issues and challenges: Rich pictureMeTA MSP workshop: Issues and challenges: Rich picture
MeTA MSP workshop: Issues and challenges: Rich picture
MeTApresents
 
Rich_Picture--IA_Manager.220131720
Rich_Picture--IA_Manager.220131720Rich_Picture--IA_Manager.220131720
Rich_Picture--IA_Manager.220131720
Thomas Callaghan
 
Program design techniques
Program design techniquesProgram design techniques
Program design techniques
fika sweety
 
AN UPDATED REVIEW ON THE CONVENTIONAL AND UNCONVENTIONAL RICH PICTURE BUILD...
AN UPDATED REVIEW ON THE  CONVENTIONAL AND UNCONVENTIONAL  RICH PICTURE BUILD...AN UPDATED REVIEW ON THE  CONVENTIONAL AND UNCONVENTIONAL  RICH PICTURE BUILD...
AN UPDATED REVIEW ON THE CONVENTIONAL AND UNCONVENTIONAL RICH PICTURE BUILD...
American Research Thoughts
 
CPI Rich Picture
CPI Rich Picture CPI Rich Picture
CPI Rich Picture
Hossam El-Shazly
 
Data Structures - Lecture 5 [Stack]
Data Structures - Lecture 5 [Stack]Data Structures - Lecture 5 [Stack]
Data Structures - Lecture 5 [Stack]
Muhammad Hammad Waseem
 
Linux vs. Windows
Linux vs. WindowsLinux vs. Windows
Linux vs. Windows
Anas R.
 
Linux vs windows
Linux vs windowsLinux vs windows
Linux vs windows
ramadansanli
 
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
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
Stack Data Structre Introduction and source code
Stack Data Structre Introduction and source codeStack Data Structre Introduction and source code
Stack Data Structre Introduction and source code
SL Coder
 
Algoritma dan Pemrograman C++ (Percabangan)
Algoritma dan Pemrograman C++ (Percabangan)Algoritma dan Pemrograman C++ (Percabangan)
Algoritma dan Pemrograman C++ (Percabangan)
Nabil Muhammad Firdaus
 
It 405 materi 2 java dasar
It 405 materi 2   java dasarIt 405 materi 2   java dasar
It 405 materi 2 java dasar
Ayi Purbasari
 
Viisio based rich picture version 2.0
Viisio based rich picture version 2.0Viisio based rich picture version 2.0
Viisio based rich picture version 2.0
Mithun112
 
Career Hub Rich Picture
Career Hub Rich PictureCareer Hub Rich Picture
Career Hub Rich Picture
guestc990b6
 
MeTA MSP workshop: Issues and challenges: Rich picture
MeTA MSP workshop: Issues and challenges: Rich pictureMeTA MSP workshop: Issues and challenges: Rich picture
MeTA MSP workshop: Issues and challenges: Rich picture
MeTApresents
 
Rich_Picture--IA_Manager.220131720
Rich_Picture--IA_Manager.220131720Rich_Picture--IA_Manager.220131720
Rich_Picture--IA_Manager.220131720
Thomas Callaghan
 
Program design techniques
Program design techniquesProgram design techniques
Program design techniques
fika sweety
 
AN UPDATED REVIEW ON THE CONVENTIONAL AND UNCONVENTIONAL RICH PICTURE BUILD...
AN UPDATED REVIEW ON THE  CONVENTIONAL AND UNCONVENTIONAL  RICH PICTURE BUILD...AN UPDATED REVIEW ON THE  CONVENTIONAL AND UNCONVENTIONAL  RICH PICTURE BUILD...
AN UPDATED REVIEW ON THE CONVENTIONAL AND UNCONVENTIONAL RICH PICTURE BUILD...
American Research Thoughts
 
Linux vs. Windows
Linux vs. WindowsLinux vs. Windows
Linux vs. Windows
Anas R.
 
Ad

Similar to Stack Data Structure V1.0 (20)

STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
devismileyrockz
 
Stack
StackStack
Stack
Maleeha Khawar Hashmie
 
Unit 3 stack
Unit 3   stackUnit 3   stack
Unit 3 stack
kalyanineve
 
Implementation of stacks and queues in C
Implementation of stacks and queues in CImplementation of stacks and queues in C
Implementation of stacks and queues in C
HarishKrishnanP
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
OliverKane3
 
Stacks.ppt
Stacks.pptStacks.ppt
Stacks.ppt
OliverKane3
 
Data Structure and Algorithms Stacks
Data Structure and Algorithms StacksData Structure and Algorithms Stacks
Data Structure and Algorithms Stacks
ManishPrajapati78
 
Stack
StackStack
Stack
Swarup Boro
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
Omprakash Chauhan
 
Data structures
Data structures Data structures
Data structures
Rokonuzzaman Rony
 
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptxData Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
RashidFaridChishti
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)
lahariit406
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.pptStack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
aamirali1061a
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
ecomputernotes
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
JeeSa Sultana
 
Stack
StackStack
Stack
Swarup Kumar Boro
 
DS1.pptx
DS1.pptxDS1.pptx
DS1.pptx
Momin24
 
13 Stacks and Queues.pptx
13 Stacks and Queues.pptx13 Stacks and Queues.pptx
13 Stacks and Queues.pptx
ssuserb7c8b8
 
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
STACK APPLICATIONS: INFOX TO POSTFIX CONVERSION AND EVALUATION OF POSTFIX EXP...
devismileyrockz
 
Implementation of stacks and queues in C
Implementation of stacks and queues in CImplementation of stacks and queues in C
Implementation of stacks and queues in C
HarishKrishnanP
 
Data Structure and Algorithms Stacks
Data Structure and Algorithms StacksData Structure and Algorithms Stacks
Data Structure and Algorithms Stacks
ManishPrajapati78
 
Stack - Data Structure - Notes
Stack - Data Structure - NotesStack - Data Structure - Notes
Stack - Data Structure - Notes
Omprakash Chauhan
 
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptxData Structures and Agorithm: DS 08 Infix to Postfix.pptx
Data Structures and Agorithm: DS 08 Infix to Postfix.pptx
RashidFaridChishti
 
Lec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptxLec5-Stack-bukc-28022024-112316am (1) .pptx
Lec5-Stack-bukc-28022024-112316am (1) .pptx
haaamin01
 
Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)Data Structures And Algorithms(stacks queues)
Data Structures And Algorithms(stacks queues)
lahariit406
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.pptStack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
aamirali1061a
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
ecomputernotes
 
Expression evaluation
Expression evaluationExpression evaluation
Expression evaluation
JeeSa Sultana
 
DS1.pptx
DS1.pptxDS1.pptx
DS1.pptx
Momin24
 
13 Stacks and Queues.pptx
13 Stacks and Queues.pptx13 Stacks and Queues.pptx
13 Stacks and Queues.pptx
ssuserb7c8b8
 
Ad

More from Zidny Nafan (6)

Materi 4 Information System Engineering Sim 1223511116853894 8
Materi 4 Information System Engineering Sim 1223511116853894 8Materi 4 Information System Engineering Sim 1223511116853894 8
Materi 4 Information System Engineering Sim 1223511116853894 8
Zidny Nafan
 
Kuliah1 Struktur Data V1.0
Kuliah1 Struktur Data V1.0Kuliah1 Struktur Data V1.0
Kuliah1 Struktur Data V1.0
Zidny Nafan
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
Zidny Nafan
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
Materi 4 Information System Engineering Sim 1223511116853894 8
Materi 4 Information System Engineering Sim 1223511116853894 8Materi 4 Information System Engineering Sim 1223511116853894 8
Materi 4 Information System Engineering Sim 1223511116853894 8
Zidny Nafan
 
Kuliah1 Struktur Data V1.0
Kuliah1 Struktur Data V1.0Kuliah1 Struktur Data V1.0
Kuliah1 Struktur Data V1.0
Zidny Nafan
 
Stack Implementation
Stack ImplementationStack Implementation
Stack Implementation
Zidny Nafan
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
Zidny Nafan
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 

Recently uploaded (20)

The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
5kW Solar System in India – Cost, Benefits & Subsidy 2025
5kW Solar System in India – Cost, Benefits & Subsidy 20255kW Solar System in India – Cost, Benefits & Subsidy 2025
5kW Solar System in India – Cost, Benefits & Subsidy 2025
Ksquare Energy Pvt. Ltd.
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Hundred applicable AI Cases for oil and Gas
Hundred applicable AI Cases for oil and GasHundred applicable AI Cases for oil and Gas
Hundred applicable AI Cases for oil and Gas
bengsoon3
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and MLGyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
GyrusAI - Broadcasting & Streaming Applications Driven by AI and ML
Gyrus AI
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
5kW Solar System in India – Cost, Benefits & Subsidy 2025
5kW Solar System in India – Cost, Benefits & Subsidy 20255kW Solar System in India – Cost, Benefits & Subsidy 2025
5kW Solar System in India – Cost, Benefits & Subsidy 2025
Ksquare Energy Pvt. Ltd.
 
TrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI PaymentsTrsLabs - Leverage the Power of UPI Payments
TrsLabs - Leverage the Power of UPI Payments
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Hundred applicable AI Cases for oil and Gas
Hundred applicable AI Cases for oil and GasHundred applicable AI Cases for oil and Gas
Hundred applicable AI Cases for oil and Gas
bengsoon3
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 

Stack Data Structure V1.0

  • 1. Stack Data Structure By : Imam M Shofi
  • 2. What is stack? A stack is a limited version of an array. New elements, or nodes as they are often called, can be added to a stack and removed from a stack only from one end. Access system a stack is referred to as a LIFO structure (Last-In First-Out) Some illustrations: stack of satay stack of CDs
  • 3. Stacks operations Push : adds a new node Push(X,S)  add the value X to the TOP of stack Pop : removes a node Pop(S)  removes the TOP node and returns its value IsEmpty : reports whether the stack is empty IsEmpty(S)  report whether the stack S is empty IsFull : reports whether the stack is full IsFull(S)  report whether the stack S is full Initialize : creates/initializes the stack Initialize(S)  create a new empty stack named S Destroy : deletes the contents of the stack (may be implemented by re-initializing the stack) Destroy(S)  deletes the contents of the stack S
  • 4. Illustration/example Operation Stack’s contents TOP value 1. Initialiaze(S) <empty> 0 2. Push(‘a’,S) a 1 3. Push(‘b’,S) a b 2 4. Push(‘c’,S) a b c 3 5. Pop(S) a b 2 6. Push(‘d’,S) a b d 3 7. Push(‘e’,S) a b d e 4 8. Pop(S) a b d 3 9. Pop(S) a b 2 10. Pop(S) a 1
  • 5. Exercise What would the state of the stack be after the following operations: create stack push A onto stack push F onto stack pop item from stack push B onto stack pop item from stack pop item from stack Show the state of the stack and the value of each variable after execution of each of the following statements: A = 5 B = 3 C = 7 (a) create stack push A onto stack push C*C onto stack pop item from stack and store in B push B+A onto stack pop item from stack and store in A pop item from stack and store in B (b) create stack push B onto stack push C onto stack push A onto stack A=B*C push A+C onto stack pop item from stack and store in A pop item from stack and store in B pop item from stack and store in C
  • 6. Converting between notations INFIX to PREFIX : (A+B) – (C*D) Do the first brace: (A+B), the PREFIX is +AB Do the second brace: (C*D), the PREFIX is *CD The end is operator -: +AB - *CD , the PREFIX is -+AB*CD INFIX to POSTFIX : (A+B) – (C*D) Do the first brace: (A+B), the POSTFIX is AB+ Do the second brace: (C*D), the POSTFIX is CD* The end is operator -: AB+ - CD* , the PREFIX is AB+CD*- PREFIX to INFIX : +/*A B C D Find the first operator: *, take 2 operands before the operator ( A and B ), the INFIX is (A*B) Find the second operator: /, take 2 operands before the operator ( A*B and C ), the INFIX is ((A*B)/C) Find the third operator: +, take 2 operands before the operator ( ((A*B)/C) and D ), the INFIX is ((A*B)/C)+D
  • 7. Converting between notations(2) PREFIX to POSTFIX : +/*A B C D Find the first operator: *, take 2 operands before the operator ( A and B ), the POSTFIX is AB* Find the second operator: /, take 2 operands before the operator ( AB* and C ), the POSTFIX is AB*C/ Find the third operator: +, take 2 operands before the operator ( AB*C/ and D ), the POSTFIX is AB*C/D+ POSTFIX to INFIX : ABCD*/- Find the first operator: *, take 2 operands before the operator ( C and D ), the INFIX is (C*D) Find the second operator: /, take 2 operands before the operator ( (C*D) and B ), the INFIX is (B/(C*D) Find the third operator: -, take 2 operands before the operator ( (B/(C*D) and A ), the INFIX is A – (B/(C*D) POSTFIX to PREFIX : ABCD*/- Find the first operator: *, take 2 operands before the operator ( C and D ), the PREFIX is *CD Find the second operator: /, take 2 operands before the operator ( *CD and B ), the PREFIX is /B*CD Find the third operator: -, take 2 operands before the operator ( /B*CD and A ), the PREFIX is -A /B*CD
  • 8. Exercise: Converting Convert these INFIX to PREFIX and POSTFIX : A / B – C / D (A + B) ^ 3 – C * D A ^ (B + C) Convert these PREFIX to INFIX and POSTFIX : + – / A B C ^ D E – + D E / X Y ^ + 2 3 – C D Convert these POSTFIX to INFIX and PREFIX : A B C + – G H + I J / * A B ^ C D + –