/
Stack Application  1: Bracket Stack Application  1: Bracket

Stack Application 1: Bracket - PowerPoint Presentation

williams
williams . @williams
Follow
66 views
Uploaded On 2023-09-21

Stack Application 1: Bracket - PPT Presentation

Matching CG1103 Data Structures and Algorithms I Ensures that pairs of brackets are properly matched eg for mathematical expressions programs A good example a bf 43df5 ID: 1019068

bracket stack closing brackets stack bracket brackets closing flag error application ex3 empty algorithms structures data cg1103 matching opening

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Stack Application 1: Bracket" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1. Stack Application 1: Bracket Matching[ CG1103 Data Structures and Algorithms I ]Ensures that pairs of brackets are properly matched.e.g., for mathematical expressions, programs A good example: {a,(b+f[4])*3,d+f[5]}Incorrect examples: (..)..) // too many closing brackets (..(..) // too many opening brackets [..(..]..) // mismatched bracketsLab1 Ex3

2. Stack Application 1: Bracket Matching[ CG1103 Data Structures and Algorithms I ]create empty stackfor every char read{ if is open bracket then push onto stack if is close bracket, then pop from the stack if doesn’t match or underflow then flag error }if stack is not empty then flag errorExample { a,( b + f [ 4 ] ) * 3, d + f [ 5 ] }Stack{([)}][]Q: What type of error does the last line test for?A: too many closing bracketsB: too many opening bracketsC: bracket mismatchLab1 Ex3