Engineering
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

answer
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 16:10, Arealbot
The force on a cutting tool are 2600n vertically downward and 2100 horizontal. determine the resultant force acting on the tool and the angle at which it acts.
Answers: 1
image
Engineering, 04.07.2019 18:10, bckyanne3
Afull journal bearing has a journal diameter of 27 mm, with a unilateral tolerance of -0.028 mm. the bushing bore has a diameter of 27.028 mm and a unilateral tolerance of 0.04 mm. the l/d ratio is 0.5. the load is 1.3 kn and the journal runs at 1200 rev/min. if the average viscosity is 50 mpa-s, find the minimum film thickness, the power loss, and the side flow for the minimum clearance assembly.
Answers: 1
image
Engineering, 04.07.2019 18:10, lowkeyqueenk
Apipe with an outside diameter of 15 cm is exposed to an ambient air and surrounding temperature of -20°c. the pipe has an outer surface temperature of 65°c and an emissivity of 0.85. if the rate of heat loss from the pipe surface is 0.95 kw per meter of length, the external convective heat transfer coefficient (h) is: (a) 12.5 w/m"k (b) 18.6 w/mk (c) 23.7 w/mk (d) 27.9 w/mk (e) 33.5 w/mk
Answers: 1
image
Engineering, 04.07.2019 18:10, Tyrant4life
Draw the engineering stress-strain curve for (a) bcc; (b) fcc metals and mark important points.
Answers: 1
Do you know the correct 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
Chemistry, 24.07.2019 13:00
Konu
Chemistry, 24.07.2019 13:00
Konu
Mathematics, 24.07.2019 13:00