SlideShare a Scribd company logo
Objectives ,[object Object],[object Object],[object Object],[object Object]
[object Object],Stacks 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
[object Object],[object Object],[object Object],[object Object],[object Object],Defining a Stack
[object Object],[object Object],[object Object],Identifying the Operations on Stacks ,[object Object],Empty Stack 1 Push an  Element 1
[object Object],Identifying the Operations on Stacks (Contd.) 1 Push an  Element 2 2 Push an  Element 3 3
[object Object],Identifying the Operations on Stacks (Contd.) 1 POP an  Element  3 2 3 POP an  Element  2
[object Object],Just a minute ,[object Object],[object Object]
[object Object],Just a minute ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Implementing a Stack Using an Array
[object Object],Implementing a Stack Using an Array (Contd.) top =  –   1  PUSH an element 3 Stack 2 1 0 4 3 Initially:
Implementing a Stack Using an Array (Contd.) 10 top =  –   1  Stack 2 1 0 4 3 PUSH an element 3
Implementing a Stack Using an Array (Contd.) 10 top = 0  Stack 2 1 0 4 3 top = 0  PUSH an element 3
Implementing a Stack Using an Array (Contd.) 10 top = 0  10 Stack 2 1 0 4 3 3 Item pushed PUSH an element 3
Implementing a Stack Using an Array (Contd.) 10 top = 0  10 Stack 2 1 0 4 3 3 PUSH an element 8
Implementing a Stack Using an Array (Contd.) 10 top = 0  10 Stack 2 1 0 4 3 3 top = 1  PUSH an element 8
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1  8 Item pushed PUSH an element 8
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1  8 PUSH an element 5
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1  8 top = 2 PUSH an element 5
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 Item pushed PUSH an element 5
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2  5 PUSH an element 1
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2  5 top = 3 PUSH an element 1
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 Item pushed PUSH an element 1
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 PUSH an element  9
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 top = 4 PUSH an element  9
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 Item pushed PUSH an element  9
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 PUSH an element  2
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 top = 5 PUSH an element  2
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 9 top = 5 Stack overflow PUSH an element  2
Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 9 ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Implementing a Stack Using an Array (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],Just a minute ,[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],Applications of Stacks
[object Object],[object Object],Implementing Function Calls
Implementing Function Calls (Contd.) Assuming these instructions at the given locations in the memory.  1100 1101 1103 1120 1121 1122 1140 1141 1102 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The execution starts from function F1 1100 1101 1103 1120 1121 1122 1140 1141 1102 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1100 1101 1103 1120 1121 1122 1140 1141 1102 Implementing Function Calls (Contd.)
x = 5 1100 1101 1103 1120 1121 1122 1140 1141 1102 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
x = 5 Address and the local variable of F1   1100 1101 1103 1120 1121 1122 1140 1141 1102 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
x = 10 1100 1101 1103 1120 1121 1122 1140 1141 1102 x = 5 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
1122, x = 10 Address and the local variable of F2  1100 1101 1103 1120 1121 1122 1140 1141 1102 x = 10 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
x = 20 Address and the local variable of F2  1100 1101 1103 1120 1121 1122 1140 1141 1102 x = 10 1122, x = 10 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
1100 1101 1103 1120 1121 1122 1140 1141 1102 20 x = 20 x = 10 1122, x = 10 1122, x = 10 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
1100 1101 1103 1120 1121 1122 1140 1141 1102 20 10 x = 5 1103, x = 5 x = 10 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],1103, x = 5
1100 1101 1103 1120 1121 1122 1140 1141 1102 20 10 5 x = 5 Implementing Function Calls (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],Maintaining the UNDO list for an Application
[object Object],[object Object],[object Object],[object Object],Checking the Nesting of Parentheses in an Expression
[object Object],[object Object],[object Object],Implementing Stacks
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],{ {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
[object Object],[object Object],[object Object],[object Object],[object Object],{ ( {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
[object Object],[object Object],[object Object],{ ( ) ( Brackets Matched {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],{ ( {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
[object Object],[object Object],[object Object],{ ( ) ( Brackets Matched {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
[object Object],[object Object],[object Object],{ ] { Brackets Do Not Match The Expression is INVALID {(a + b)  ×  (c + d) ]} Implementing Stacks (Contd.)
Algorithm for Balanced Symbol Checking ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Evaluating Expressions ,[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary (Contd.) ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Clips basics how to make expert system in clips | facts adding | rules makin...
Clips basics  how to make expert system in clips | facts adding | rules makin...Clips basics  how to make expert system in clips | facts adding | rules makin...
Clips basics how to make expert system in clips | facts adding | rules makin...
NaumanMalik30
 
Understanding Lemon Generated Parser Final
Understanding Lemon Generated Parser FinalUnderstanding Lemon Generated Parser Final
Understanding Lemon Generated Parser Final
vivekanandan r
 
Event Stream Processing with Multiple Threads
Event Stream Processing with Multiple ThreadsEvent Stream Processing with Multiple Threads
Event Stream Processing with Multiple Threads
Sylvain Hallé
 
The Ring programming language version 1.3 book - Part 18 of 88
The Ring programming language version 1.3 book - Part 18 of 88The Ring programming language version 1.3 book - Part 18 of 88
The Ring programming language version 1.3 book - Part 18 of 88
Mahmoud Samir Fayed
 
Understanding Lemon Generated Parser
Understanding Lemon Generated ParserUnderstanding Lemon Generated Parser
Understanding Lemon Generated Parser
vivekanandan r
 
Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11
Stefano Leli
 
The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.6 book - Part 34 of 189The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.6 book - Part 34 of 189
Mahmoud Samir Fayed
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
Bayu Aldi Yansyah
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
Chan Shik Lim
 
Process management
Process managementProcess management
Process management
Utkarsh Kulshrestha
 
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88
Mahmoud Samir Fayed
 
Knight's Tour
Knight's TourKnight's Tour
Knight's Tour
Veysi Ertekin
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
gekiaruj
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
Maxim Kulsha
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
Dr. Volkan OBAN
 
Haskell 101
Haskell 101Haskell 101
Haskell 101
Roberto Pepato
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.
Douglas Starnes
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.
lnikolaeva
 
The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189
Mahmoud Samir Fayed
 

What's hot (20)

Clips basics how to make expert system in clips | facts adding | rules makin...
Clips basics  how to make expert system in clips | facts adding | rules makin...Clips basics  how to make expert system in clips | facts adding | rules makin...
Clips basics how to make expert system in clips | facts adding | rules makin...
 
Understanding Lemon Generated Parser Final
Understanding Lemon Generated Parser FinalUnderstanding Lemon Generated Parser Final
Understanding Lemon Generated Parser Final
 
Event Stream Processing with Multiple Threads
Event Stream Processing with Multiple ThreadsEvent Stream Processing with Multiple Threads
Event Stream Processing with Multiple Threads
 
The Ring programming language version 1.3 book - Part 18 of 88
The Ring programming language version 1.3 book - Part 18 of 88The Ring programming language version 1.3 book - Part 18 of 88
The Ring programming language version 1.3 book - Part 18 of 88
 
Understanding Lemon Generated Parser
Understanding Lemon Generated ParserUnderstanding Lemon Generated Parser
Understanding Lemon Generated Parser
 
Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11Codice legacy, usciamo dal pantano! @iad11
Codice legacy, usciamo dal pantano! @iad11
 
The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.6 book - Part 34 of 189The Ring programming language version 1.6 book - Part 34 of 189
The Ring programming language version 1.6 book - Part 34 of 189
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Process management
Process managementProcess management
Process management
 
The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88The Ring programming language version 1.3 book - Part 13 of 88
The Ring programming language version 1.3 book - Part 13 of 88
 
Knight's Tour
Knight's TourKnight's Tour
Knight's Tour
 
Slides
SlidesSlides
Slides
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
Python легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачиPython легко и просто. Красиво решаем повседневные задачи
Python легко и просто. Красиво решаем повседневные задачи
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
 
Haskell 101
Haskell 101Haskell 101
Haskell 101
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.
 
TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.TCO in Python via bytecode manipulation.
TCO in Python via bytecode manipulation.
 
The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189The Ring programming language version 1.6 book - Part 84 of 189
The Ring programming language version 1.6 book - Part 84 of 189
 

Similar to Stacks

U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
Ssankett Negi
 
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
RashidFaridChishti
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
SherinRappai
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
Corrado Santoro
 
Stack
StackStack
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
maamir farooq
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
pinakspatel
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
nikshaikh786
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arraystameemyousaf
 
stack-Intro.pptx
stack-Intro.pptxstack-Intro.pptx
stack-Intro.pptx
DEEPAK948083
 
Note introductions of functions
Note introductions of functionsNote introductions of functions
Note introductions of functions
SMK Tengku Intan Zaharah
 
Introduction to functions
Introduction to functionsIntroduction to functions
Introduction to functions
Elkin Guillen
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
Senthil Kumar
 
Stacks, Queues, Deques
Stacks, Queues, DequesStacks, Queues, Deques
Stacks, Queues, Deques
A-Tech and Software Development
 
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Paulo Miguel Almeida
 
Lect-28-Stack-Queue.ppt
Lect-28-Stack-Queue.pptLect-28-Stack-Queue.ppt
Lect-28-Stack-Queue.ppt
ThekkepatSankalp
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
Stack linked list
Stack linked listStack linked list
Stack linked listbhargav0077
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
kumarkaushal17
 

Similar to Stacks (20)

U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
Data Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptxData Structures and Agorithm: DS 06 Stack.pptx
Data Structures and Agorithm: DS 06 Stack.pptx
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
Stack
StackStack
Stack
 
Data structures stacks
Data structures   stacksData structures   stacks
Data structures stacks
 
Stacks,queues,linked-list
Stacks,queues,linked-listStacks,queues,linked-list
Stacks,queues,linked-list
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
 
stack-Intro.pptx
stack-Intro.pptxstack-Intro.pptx
stack-Intro.pptx
 
Note introductions of functions
Note introductions of functionsNote introductions of functions
Note introductions of functions
 
Introduction to functions
Introduction to functionsIntroduction to functions
Introduction to functions
 
My lecture stack_queue_operation
My lecture stack_queue_operationMy lecture stack_queue_operation
My lecture stack_queue_operation
 
Stacks, Queues, Deques
Stacks, Queues, DequesStacks, Queues, Deques
Stacks, Queues, Deques
 
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
Auckland Programming Algorithms and Performance Meetup about Stacks & LeetCod...
 
Lect-28-Stack-Queue.ppt
Lect-28-Stack-Queue.pptLect-28-Stack-Queue.ppt
Lect-28-Stack-Queue.ppt
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
Lecture2
Lecture2Lecture2
Lecture2
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
 

Recently uploaded

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Stacks

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Implementing a Stack Using an Array (Contd.) 10 top = – 1 Stack 2 1 0 4 3 PUSH an element 3
  • 12. Implementing a Stack Using an Array (Contd.) 10 top = 0 Stack 2 1 0 4 3 top = 0 PUSH an element 3
  • 13. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 Item pushed PUSH an element 3
  • 14. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 PUSH an element 8
  • 15. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 top = 1 PUSH an element 8
  • 16. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 Item pushed PUSH an element 8
  • 17. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 PUSH an element 5
  • 18. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 top = 2 PUSH an element 5
  • 19. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 Item pushed PUSH an element 5
  • 20. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 PUSH an element 1
  • 21. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 top = 3 PUSH an element 1
  • 22. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 Item pushed PUSH an element 1
  • 23. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 PUSH an element 9
  • 24. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 top = 4 PUSH an element 9
  • 25. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 Item pushed PUSH an element 9
  • 26. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 PUSH an element 2
  • 27. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 top = 5 PUSH an element 2
  • 28. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 9 top = 5 Stack overflow PUSH an element 2
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.

Editor's Notes

  1. To start the session, you need to get a set of playing cards in the class. Follow the instructions as given below to begin the game of Rummy. 1. The game begins by dealing a fixed number of cards to all players. The remaining cards are placed face down to form a “stock” pile. 2. There is also a face-up pile called the “discard” pile. 3. Initially, the discard pile contains only one card which is obtained by picking the topmost card from the stock pile. 4. Each player can draw either the topmost card of the stock pile or the topmost card on the discard pile to make a valid sequence in his/her hand. 5. After this, the player must discard one card on top of the discard pile. 6. The next player, can then draw either the topmost card of the draw pile or the topmost card of the discard pile. 7. Therefore, if a player has to draw a card from the discard pile, he/she can draw only the topmost card of the discard pile. 8. Similarly, when a player has to discard a card, he/she must discard it on the top of the discard pile. 9. The discard pile can therefore be considered a Last-In-First-Out list. 10. The last card placed on top of the discard pile is the first one to be drawn. 11. To represent and manipulate this kind of a discard pile in a computer program, you would like to use a list that: a. Contains the details of all the cards in the discard pile. b. Implements insertion and deletion of card details in such a way that the last inserted card is the first one to be removed. This kind of a list can be implemented by using a stack. Ask students to define a stack? Ask them to refer to the game and come up with some characteristics of a stack. Then come to next slide and give them the definition of stacks.
  2. You can give some more explanation of stacks by with the help of the following example. 1. A stack is like an empty box containing books, which is just wide enough to hold the books in one pile. 2. The books can be placed as well as removed only from the top of the box. 3. The book most recently put in the box is the first one to be taken out. 4. The book at the bottom is the first one to be put inside the box and the last one to be taken out.
  3. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  4. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  5. Tell students that stacks can be implemented using both arrays and Linked List. The slides to explain the implementation of stacks using an array are given.
  6. Make this session an interactive one by asking students to write an algorithm to implement POP operation using an array. Let students first try to write the algorithm. Then you can explain the algorithm given in the student guide. In addition, also explain the exception conditions that is encountered while popping an element from the stack, using an array.
  7. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  8. In this section, you need to discuss the applications of Stacks. In addition, to the given applications, you can discuss some real life applications also. For example, ask students to notice the operations in their Mobile phones. When you go to the Menu  log  Recent calls  Missed calls. On the missed call page, you will be able to view all the missed call number. To back to the main page, you need to press the back option and it will take you page, you last visited.
  9. In this section, you need to discuss the applications of Stacks. In addition, to the given applications, you can discuss some real life applications also. For example, ask students to notice the operations in their Mobile phones. When you go to the Menu  log  Recent calls  Missed calls. On the missed call page, you will be able to view all the missed call number. To back to the main page, you need to press the back option and it will take you page, you last visited.
  10. Explain this concept to students by further telling them that the changes are internally stored in the stack data structure inside the computer. The last change made is the first one to be reverted.
  11. In this slide, ask students to relate to the example they have learnt in the beginning of the session.
  12. This is one of the applications where stack is used. You need to run through the slides and then ask students to write an algorithm to check the correctness of the nested parenthesis. The algorithm will be: Scan the expression. Push the opening bracket into the stack. If a closing bracket is encountered, check if the closing bracket is same as the opening bracket. If this condition holds true, POP the corresponding opening bracket from the stack. If the condition is false, the expression is not a valid expression.
  13. In this slide, ask students to relate to the example they have learnt in the beginning of the session.