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

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Water in a partially filled large tank is to be supplied to the roof top, which is 8 m above the water level in the tank, through a 2.2-cm-internal-diameter pipe by maintaining a constant air pressure of 300 kpa (gage) in the tank. if the head loss in the piping is 2 m of water, determine the discharge rate of the supply of water to the roof top in liters per second.
Answers: 3
question
Engineering, 04.07.2019 18:10
Carbon dioxide gas expands isotherm a turbine from 1 mpa, 500 k at 200 kpa. assuming the ideal gas model and neglecting the kinetic and potential energies, determine the change in entropy, heat transfer and work for each kilogram of co2.
Answers: 2
question
Engineering, 04.07.2019 18:10
You are making beer. the first step is filling the glass carboy with the liquid wort. the internal diameter of the carboy is 15 in., and you wish to fill it up to a depth of 2 ft. if your wort is drawn from the kettle using a siphon process that flows at 3 gpm, how long will it take to fill?
Answers: 1
question
Engineering, 04.07.2019 18:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
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
question
Mathematics, 20.03.2020 01:24
question
Mathematics, 20.03.2020 01:25
Questions on the website: 13722361