subject
Engineering, 24.04.2020 16:00 rainbowsadie7140

Using a stack to check order of parenthesis (20 points) In this program, you will read your inputs from a file input. txt, which will contain multiple lines with different sequences of brackets. You task is to create a class ParenthesisMatch. java, with two method s isParenthesisMatch and main. The main method will read the input. txt file, which will contain the following example inputs. The main method will read each line from the file, and pass the string to the isParenthesisMatch method. The isParenthesis method will check if the order of the parenthesis is valid, and will return a Boolean true/false. E. g. for the above lines, the outputs will be true true true true false false false The above problem can be easily solved using a stack. The algorithm is that, as you scan each character in the string of parenthesis, every time you see a '(', then you push it in the stack. Otherwise, if you see a '),, you check if the current top of stack ?s('Jfitis, then you pop it out of the stack. Otherwise, if the stack is empty, or if the current top is not you return false. Finally, when all the characters in the string is scanned, and if the stack is empty, you return true. Otherwise, if the scanning of the string is competed, but the stack is not empty, you return false. Use the pseudocode below to solve the problem as described For each character C in string of parenthesis If C is then push C in stack Else if C is')', thern If stack is empty, then return false Else if top of stack is (', then pop element from stack Else return false Return true if stack is empty, or false otherwise

ansver
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 19:30, 10040813
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
image
Engineering, 04.07.2019 18:10, krystabrewer3
What are the two (02) benefits, which may result from a successful implementation of preventive maintenance (pm) program in an organization? (clo3)a)- lean manufacturing b)-overlapping responsibilities c)-the planner is not qualified d)-accurate contractor information e)-reduction in equipment redundancies f)-accurate stores information
Answers: 3
image
Engineering, 04.07.2019 18:20, CelesteN64
Most leaks in reciprocating air compressors can be detected and minimized by: (clo4) a)-detecting leakage areas using ultrasonic acoustic detector. b)-tightening joints and connections c)-replacing faulty equipment d)-all of the given options
Answers: 2
image
Engineering, 04.07.2019 18:20, alexis9263
Have a greater impact on maintenance productivity than any other support group. (clo5) a)-the top management b)-inventory and purchasing c)-sub-contracting d)-cmms
Answers: 2
You know the right answer?
Using a stack to check order of parenthesis (20 points) In this program, you will read your inputs f...

Questions in other subjects:

Konu
Mathematics, 01.03.2021 18:20
Konu
Mathematics, 01.03.2021 18:20
Konu
Chemistry, 01.03.2021 18:20