SlideShare a Scribd company logo
1 of 26
Part-B1   Stacks
Abstract Data Types (ADTs) ,[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 Stack ADT (§4.2) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Stack Interface in Java ,[object Object],[object Object],public interface   Stack   { public  int  size() ; public  boolean  isEmpty() ; public  Object  top() throws   EmptyStackException ; public void   push(Object o) ; public  Object  pop()   throws   EmptyStackException ; }
Exceptions ,[object Object],[object Object],[object Object],[object Object]
Applications of Stacks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array-based Stack  (Implementation)   ,[object Object],[object Object],[object Object],S 0 1 2 t … Algorithm   size () return   t  +   1 Algorithm   pop () if   isEmpty ()   then throw  EmptyStackException   else  t      t      1 return   S [ t  +   1]
Array-based Stack (cont.) ,[object Object],[object Object],[object Object],[object Object],Algorithm   push ( o ) if   t   =   S.length      1   then throw  FullStackException   else  t      t  +   1 S [ t ]     o S 0 1 2 t …
Array-based Stack  (Cont.)  ,[object Object],[object Object],S 0 1 2 t … Algorithm   isEmpty() if   t<0   then   return   true else   return   false Algorithm   top () if   isEmpty ()   then throw  EmptyStackException   return   S [ t  ]
Performance and Limitations for array-based Stack ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array-based Stack in Java public class   ArrayStack  implements  Stack { // holds the stack elements   private  Object S[ ]; // index to top element private  int top = -1; // constructor public   ArrayStack(int capacity)   {   S = new Object[capacity]);   }
Array-based Stack in Java public  Object  pop()   throws   EmptyStackException { if  isEmpty() throw new   EmptyStackException (“ Empty stack: cannot pop ”); Object temp = S[top]; // facilitates garbage collection   S[top] =   null ; top = top – 1; return   temp;   } public  int  size()   { return  (top + 1);
Array-based Stack in Java public boolean isEmpty() { return (top < 0); } public void push(Object obj) throws FullStackException { if (size() == capacity) throw new FullStackException(&quot;Stack overflow.&quot;); S[++top] = obj; } public Object top() throws EmptyStackException { if (isEmpty()) throw new EmptyStackException(&quot;Stack is empty.&quot;); return S[top]; }
Parentheses Matching ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Parentheses Matching Algorithm ,[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]
Parentheses Matching Example 1 ,[object Object],([ Push  [  [ 5 ( Pop  ( Test if ( and X[i] match?  YES ) 4 (( Push ( ( 3 ( Push ( ( 2 Pop  (  Test if  ( and X[i] match?  YES ) 1 ( Push ( ( 0 Output Stack Operation X[i] i
Parentheses Matching Example 1 ,[object Object],Pop ( Test if ( and X[i]  match?  YES ) 9 TRUE Test if  stack is Empty?  YES ( Pop  [ Test if  [ and X[i] match?  YES ] 8 ([ Pop  ( Test if  ( and X[i] match?  YES ) 7 ([( Push ( ( 6 Output Stack Operation X[i] i
Parentheses Matching Example 2 ,[object Object],FASLE Pop ( Test if ( and X[i] match ?  NO  ] 5 ( Pop  [ Test if [ and X[i] match?  YES ] 4 ([ Push [ [ 3 ( Pop  ( Test if ( and X[i] match?  YES ) 2 (( Push ( ( 1 ( Push ( ( 0 Output Stack Operation X[i] i
Computing Spans (not in book) ,[object Object],[object Object],[object Object],[object Object],X S 1 3 2 1 1 2 5 4 3 6
Quadratic Algorithm Algorithm   spans1 ( X, n ) Input   array  X  of  n  integers Output   array  S  of spans of  X   # S      new array of  n  integers   n for   i      0   to   n     1   do n s     1 n while  s     i      X [ i   s ]      X [ i -s+1 ]   1   2   …   ( n     1)   s      s     1   1   2   …   ( n     1) S [ i ]      s     n return   S    1 X[]= 1,2,3, …, n-1, n. ,[object Object]
Computing Spans with a Stack ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example:  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Linear Algorithm Algorithm   spans2 ( X, n )   # S      new array of  n  integers     n A      new empty stack     1 for   i      0   to   n     1   do A.push(i)   n   i=n-1  ;  j=n-1 ;  1 while  (i<=0)  do  while   (  A . isEmpty ()     X [ A.top ()]      X [ j ]  )   do   n   j      A.pop ()   n   if  A . isEmpty ()   then       n S [ i ]      i     1   1   else   S [ i ]      i    j +1  n i=j-1;   n return   S      1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary of Stack  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Week 3: Tutorial Arrangement ,[object Object],City Uni. Lift 18 Tunnel connecting city U and Festival Walk
Remarks ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureNurjahan Nipa
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesPriyanka Rana
 
Queues presentation
Queues presentationQueues presentation
Queues presentationToseef Hasan
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )swapnac12
 
Conctructing Polytopes via a Vertex Oracle
Conctructing Polytopes via a Vertex OracleConctructing Polytopes via a Vertex Oracle
Conctructing Polytopes via a Vertex OracleVissarion Fisikopoulos
 
lecture 10
lecture 10lecture 10
lecture 10sajinsc
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine LearningBig_Data_Ukraine
 
The Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterateThe Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iteratePhilip Schwarz
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaPriyanka Rana
 
Priority queues and heap sorting
Priority queues and heap sortingPriority queues and heap sorting
Priority queues and heap sortingheshekik
 

What's hot (20)

Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structure
 
Queue
QueueQueue
Queue
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7
 
Best,worst,average case .17581556 045
Best,worst,average case .17581556 045Best,worst,average case .17581556 045
Best,worst,average case .17581556 045
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority QueuesHeaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
 
Queues presentation
Queues presentationQueues presentation
Queues presentation
 
E10
E10E10
E10
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )Asymptotic notations(Big O, Omega, Theta )
Asymptotic notations(Big O, Omega, Theta )
 
Priority queues
Priority queuesPriority queues
Priority queues
 
Conctructing Polytopes via a Vertex Oracle
Conctructing Polytopes via a Vertex OracleConctructing Polytopes via a Vertex Oracle
Conctructing Polytopes via a Vertex Oracle
 
lecture 10
lecture 10lecture 10
lecture 10
 
Circular queue
Circular queueCircular queue
Circular queue
 
Introduction to Machine Learning
Introduction to Machine LearningIntroduction to Machine Learning
Introduction to Machine Learning
 
The Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterateThe Functional Programming Triad of fold, scan and iterate
The Functional Programming Triad of fold, scan and iterate
 
Maps&hash tables
Maps&hash tablesMaps&hash tables
Maps&hash tables
 
Algorithms DM
Algorithms DMAlgorithms DM
Algorithms DM
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/ThetaAlgorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
 
Shunting yard
Shunting yardShunting yard
Shunting yard
 
Priority queues and heap sorting
Priority queues and heap sortingPriority queues and heap sorting
Priority queues and heap sorting
 

Viewers also liked

The Hackathon Zoo
The Hackathon ZooThe Hackathon Zoo
The Hackathon ZooKevin Lewis
 
Con8896 securely enabling mobile access for business transformation - final
Con8896  securely enabling mobile access for business transformation - finalCon8896  securely enabling mobile access for business transformation - final
Con8896 securely enabling mobile access for business transformation - finalOracleIDM
 
То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
 То, что вы хотели знать о HandlerSocket, но не смогли нагуглить То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
То, что вы хотели знать о HandlerSocket, но не смогли нагуглитьSergey Xek
 
Educ 2190 mathematics stage 5 – year 10 – statistics
Educ 2190   mathematics stage 5 – year 10 – statisticsEduc 2190   mathematics stage 5 – year 10 – statistics
Educ 2190 mathematics stage 5 – year 10 – statisticsMatthew Lovegrove
 
Egoera: La Economía de Bizkaia - Junio 2016 - nº23
Egoera: La Economía de Bizkaia - Junio 2016 - nº23Egoera: La Economía de Bizkaia - Junio 2016 - nº23
Egoera: La Economía de Bizkaia - Junio 2016 - nº23Cámara de Comercio de Bilbao
 
Social challenges exposition
Social challenges expositionSocial challenges exposition
Social challenges expositionDilsy Sandoval
 
Маркетинговая программа "Быстрого роста 3+3"
Маркетинговая программа "Быстрого роста 3+3"Маркетинговая программа "Быстрого роста 3+3"
Маркетинговая программа "Быстрого роста 3+3"Елена Шальнова
 
58 c8921e e1fe-408b-bb39ff295ee367b9
58 c8921e e1fe-408b-bb39ff295ee367b958 c8921e e1fe-408b-bb39ff295ee367b9
58 c8921e e1fe-408b-bb39ff295ee367b9Carlos Carvalho
 
Wellbeing 2011 Fact Sheet English
Wellbeing 2011  Fact  Sheet  EnglishWellbeing 2011  Fact  Sheet  English
Wellbeing 2011 Fact Sheet EnglishCheryl Deguara
 
McCrindle Research Pty Ltd
McCrindle Research Pty LtdMcCrindle Research Pty Ltd
McCrindle Research Pty Ltdjohnarthur101
 

Viewers also liked (20)

The Hackathon Zoo
The Hackathon ZooThe Hackathon Zoo
The Hackathon Zoo
 
Con8896 securely enabling mobile access for business transformation - final
Con8896  securely enabling mobile access for business transformation - finalCon8896  securely enabling mobile access for business transformation - final
Con8896 securely enabling mobile access for business transformation - final
 
Notam 15 04
Notam 15 04Notam 15 04
Notam 15 04
 
ขั้นตอนศาสนพิธี
ขั้นตอนศาสนพิธีขั้นตอนศาสนพิธี
ขั้นตอนศาสนพิธี
 
То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
 То, что вы хотели знать о HandlerSocket, но не смогли нагуглить То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
То, что вы хотели знать о HandlerSocket, но не смогли нагуглить
 
PNY Power Bank Series for Smart Devices
PNY Power Bank Series for Smart DevicesPNY Power Bank Series for Smart Devices
PNY Power Bank Series for Smart Devices
 
Educ 2190 mathematics stage 5 – year 10 – statistics
Educ 2190   mathematics stage 5 – year 10 – statisticsEduc 2190   mathematics stage 5 – year 10 – statistics
Educ 2190 mathematics stage 5 – year 10 – statistics
 
Solarpower by holly
Solarpower by hollySolarpower by holly
Solarpower by holly
 
Egoera: La Economía de Bizkaia - Junio 2016 - nº23
Egoera: La Economía de Bizkaia - Junio 2016 - nº23Egoera: La Economía de Bizkaia - Junio 2016 - nº23
Egoera: La Economía de Bizkaia - Junio 2016 - nº23
 
Social challenges exposition
Social challenges expositionSocial challenges exposition
Social challenges exposition
 
Back to the future of hr@ams
Back to the future of hr@amsBack to the future of hr@ams
Back to the future of hr@ams
 
Sports in england
Sports in englandSports in england
Sports in england
 
Маркетинговая программа "Быстрого роста 3+3"
Маркетинговая программа "Быстрого роста 3+3"Маркетинговая программа "Быстрого роста 3+3"
Маркетинговая программа "Быстрого роста 3+3"
 
Quiet hotelroom
Quiet hotelroomQuiet hotelroom
Quiet hotelroom
 
58 c8921e e1fe-408b-bb39ff295ee367b9
58 c8921e e1fe-408b-bb39ff295ee367b958 c8921e e1fe-408b-bb39ff295ee367b9
58 c8921e e1fe-408b-bb39ff295ee367b9
 
Begin scripting
Begin scriptingBegin scripting
Begin scripting
 
Preghiera a San Michele Arcangelo E-book
Preghiera a  San Michele Arcangelo E-bookPreghiera a  San Michele Arcangelo E-book
Preghiera a San Michele Arcangelo E-book
 
Wellbeing 2011 Fact Sheet English
Wellbeing 2011  Fact  Sheet  EnglishWellbeing 2011  Fact  Sheet  English
Wellbeing 2011 Fact Sheet English
 
McCrindle Research Pty Ltd
McCrindle Research Pty LtdMcCrindle Research Pty Ltd
McCrindle Research Pty Ltd
 
IHC Ace PPT
IHC Ace PPTIHC Ace PPT
IHC Ace PPT
 

Similar to Lecture2

Similar to Lecture2 (20)

Lec2
Lec2Lec2
Lec2
 
stack (1).pptx
stack (1).pptxstack (1).pptx
stack (1).pptx
 
Lec2
Lec2Lec2
Lec2
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
 
Stack linked list
Stack linked listStack linked list
Stack linked list
 
U3.stack queue
U3.stack queueU3.stack queue
U3.stack queue
 
stack presentation
stack presentationstack presentation
stack presentation
 
Stacks queues
Stacks queuesStacks queues
Stacks queues
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Stack concepts by Divya
Stack concepts by DivyaStack concepts by Divya
Stack concepts by Divya
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Lecture 4 - List, Stack, Queues, Deques.pdf
Lecture 4 - List, Stack, Queues, Deques.pdfLecture 4 - List, Stack, Queues, Deques.pdf
Lecture 4 - List, Stack, Queues, Deques.pdf
 
Stacks
StacksStacks
Stacks
 
01-intro_stacks.ppt
01-intro_stacks.ppt01-intro_stacks.ppt
01-intro_stacks.ppt
 
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
 
Data Structure.pptx
Data Structure.pptxData Structure.pptx
Data Structure.pptx
 
Educational slides by venay magen
Educational slides by venay magenEducational slides by venay magen
Educational slides by venay magen
 
Python programming : Arrays
Python programming : ArraysPython programming : Arrays
Python programming : Arrays
 
DS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptxDS MOD2 (1) (1).pptx
DS MOD2 (1) (1).pptx
 

More from FALLEE31188 (20)

Lecture4
Lecture4Lecture4
Lecture4
 
L16
L16L16
L16
 
L2
L2L2
L2
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Functions
FunctionsFunctions
Functions
 
Field name
Field nameField name
Field name
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Cis068 08
Cis068 08Cis068 08
Cis068 08
 
Chapter14
Chapter14Chapter14
Chapter14
 
Chapt03
Chapt03Chapt03
Chapt03
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
Brookshear 06
Brookshear 06Brookshear 06
Brookshear 06
 
Book ppt
Book pptBook ppt
Book ppt
 
Assignment 2
Assignment 2Assignment 2
Assignment 2
 
Assignment
AssignmentAssignment
Assignment
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
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
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
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
 
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"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet 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
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 

Lecture2

  • 1. Part-B1 Stacks
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Array-based Stack in Java public class ArrayStack implements Stack { // holds the stack elements private Object S[ ]; // index to top element private int top = -1; // constructor public ArrayStack(int capacity) { S = new Object[capacity]); }
  • 12. Array-based Stack in Java public Object pop() throws EmptyStackException { if isEmpty() throw new EmptyStackException (“ Empty stack: cannot pop ”); Object temp = S[top]; // facilitates garbage collection S[top] = null ; top = top – 1; return temp; } public int size() { return (top + 1);
  • 13. Array-based Stack in Java public boolean isEmpty() { return (top < 0); } public void push(Object obj) throws FullStackException { if (size() == capacity) throw new FullStackException(&quot;Stack overflow.&quot;); S[++top] = obj; } public Object top() throws EmptyStackException { if (isEmpty()) throw new EmptyStackException(&quot;Stack is empty.&quot;); return S[top]; }
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.