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, 03.07.2019 15:10
Apiston-cylinder with a volume of 0.25 m3 holds 1 kg of air (r 0.287 k/kgk) at a temperature of 100 c. heat transfer to the cylinder causes an isothermal expansion of the piston until the volume triples. how much heat is added to the piston-cylinder?
Answers: 3
question
Engineering, 03.07.2019 15:10
Two flowing streams of argon gas are adiabatically mixed to form a single flow/stream. one stream is 1.5 kg/s at 400 kpa and 200 c while the second stream is 2kg/s at 500 kpa and 100 ? . it is stated that the exit state of the mixed single flow of argon gas is 150 c and 300 kpa. assuming there is no work output or input during the mixing process, does this process violate either the first or the second law or both? explain and state all your assumptions.
Answers: 1
question
Engineering, 04.07.2019 18:10
Refrigerant 134a enters an insulated compressor operating at steady state as saturated vapor at -26°c with a volumetric flow rate of 0.18 m3/s. refrigerant exits at 9 bar, 70°c. changes in kinetic and potential energy from inlet to exit can be ignored. determine the volumetric flow rate at the exit, in m3/s, and the compressor power, in kw.
Answers: 1
question
Engineering, 04.07.2019 18:10
The filament of an incandescent lamp has a temperature of 2000k. calculate the fraction of radiation emitted in the visible light band if the filament is approximated as blackbody
Answers: 2
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, 21.04.2020 16:12
question
Mathematics, 21.04.2020 16:12
question
Arts, 21.04.2020 16:12
question
Mathematics, 21.04.2020 16:12
Questions on the website: 13722361