subject
Engineering, 21.02.2020 17:48 nurikchan

A classic use of a stack if for checking whether an expression that contains a set of different kinds of bracketing (namely parentheses, square brackets, curly brackets, angle brackets) is "well formed". Such an expression is considered "well formed" if the open brackets match exactly the close brackets. This problem represents one portion of the design of a compiler that needs to check that all such pairs of brackets are properly balanced and nested. You will write a method that checks a given expression (a String) with characters and brackets ("O", "O", "O", "<>"), determine if it is well-formed by using the following algorithm in conjunction with a stack. . Check the expression character by character. If the character is an opening bracket (characters , T. '{:'<), then push it onto the stack • Else if the character is a closing bracket (characters ), 1', '},">'), then: . Check if the stack is empty. If it is, then there is no matching opening bracket. The expression is not well formed. • If the stack is not empty, pop the top character off the stack, compare the current closing bracket to the top character. If they are matched brackets, continue to read next character in the expression; if they are not matched brackets, the expression is not well formed. • If the end of the expression is reached, check if the stack is empty. If it is, the expression is well-formed. Otherwise, it is not well-formed.

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 19:10
A)-in the process of engineering design, explain the contribution of material selection. b)- explain the procedure of synthesis as is employed in engineering design. c)- is there any relationship between ergonomics and engineering design? explain. d)- safety consideration in engineering design includes human, product and the enviroment . explain how safety will be incorporated into the design?
Answers: 3
question
Engineering, 04.07.2019 19:20
Apiping systems consists of 6 m of 6-std type k and 12 m of 4-std type k, both drawn copper tubing. the system conveys ethylene glycol at a rate of 0.013 m3/s. the pressure drop across the system is to be calculated. there are two 90° elbows in the 6-in pipe, a reduction from the 6-in pipe to the 4-in pipe and four 90° elbows in the 4-in pipe. all fittings are soldered (same as flanged) and regular. the inlet and outlet of the system are at the same height.
Answers: 1
question
Engineering, 06.07.2019 02:30
A12 mm diameter shaft runs in a plain cylindrical bush 30 mm long that is located in an 18 mm diameter hole in a housing. the shaft-inner bush fit is h8 f and the outer bush-housing fit is h7-p6. make a fully cimensioned sketch of the bush with tolerances. find the maximum and minimum clearance or interference for both fits on the inner and outer diameters of the bush
Answers: 3
You know the right answer?
A classic use of a stack if for checking whether an expression that contains a set of different kind...
Questions
question
English, 03.12.2021 20:20
question
Mathematics, 03.12.2021 20:20
question
Mathematics, 03.12.2021 20:20