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:20
A3-mm-thick panel of aluminum alloy (k 177 w/m-k, c 875 j/kg-k and ? = 2770 kg/m) is finished on both sides with an epoxy coating that must be cured at or above t,-150°c for at least 5 min. the production line for the curing operation involves two steps: (1) heating in a large oven with air at ts,0-175°c and a convection coefficient of h, 40 w/m2. k, and (2) cooling in a large chamber with air at 25°c and a con- vection coefficient of he 10 w/m2.k. the heating portion of the process is conducted over a time interval te which exceeds the ime required to reach 150°c by 5 min (h = r + 300 s). the coating has an emissivity of ? = 0.8, and the temperatures of the oven and chamber walls are 175 and 25°c, respectively. if the panel is placed in the oven at an initial temperature of 25°c and removed from the chamber at a safe-to-touch tempera ture of 37°c, what is the total elapsed time for the two-step curing operation?
Answers: 3
question
Engineering, 04.07.2019 19:20
Air enters a horizontal, constant-diameter heating duct operating at steady state at 290 k, 1 bar, with a volumetric flow rate of 0.25 m°/s, and exits at 325 k, 0.95 bar. the flow area is 0.04 m2. assuming the ideal gas model with k = 1.4 for the air, determine (a) the velocity at the inlet and exit, each in m/s, and (c) the rate of heat transfer, in kw flow rate, in kg/s, (b) the mass kg 0.3
Answers: 2
question
Engineering, 04.07.2019 19:20
Consider airflow over a flat plate of length l = 1.5 m under conditions for which transition occurs at le = 0.9 m based on the critical reynolds number, re,e = 5 x 10. evaluating the thermophysical properties of air at 400 k, determine the air velocity. (hint: use the tables to find the properties of air)
Answers: 3
question
Engineering, 04.07.2019 19:20
To design a steam turbine to produce 12,000 hp power. a engineer comsiders using a steady state stean low st 1160fr and engineer considers using a steady state steam flow at 1160°r and 450 psia to drive this steam turbine. the exhaust of the steam is cooled by the lake (vacuum). heat losing to the surroundings is measured at a rate of 555.55 btu/s. (a) sketch the system with the given conditions. (b) neglecting kinetic and potential energy changes from inlet to exit, determine the volumetric flow rate of the steam at the inlet, (ft'/hr). must clearly show unit conversions at crtical terms.
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
Business, 28.03.2021 07:20
question
Chemistry, 28.03.2021 07:20
question
Social Studies, 28.03.2021 07:20
Questions on the website: 13722360