Engineering
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.

answer
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 03.07.2019 15:10, breannaasmith1122
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
image
Engineering, 04.07.2019 18:20, miguel454545
Along 8-cm diameter steam pipe whose external surface temperature is 900c connects two buildings. the pipe is exposed to ambient air at 70c with a wind speed of 50 km/hr blowing across the pipe. determine the heat loss from the pipe per unit length. (b) air at 500c enters a section of a rectangular duct (15 cm x 20 cm) at an average velocity of 7 m/s. if the walls of the duct are maintained at 100c. a) the length of the tube for an exit temperature of the air to be 40 0c. b)the rate of heat transfer from the air. c) the fan power needed to overcome the pressure drop in this section of the duct.
Answers: 1
image
Engineering, 06.07.2019 02:30, jayjay5246
Air (c-1.006 kj/kg. k, r-0.287 kj/kg. k) enters a nozzle steadily at 280 kpa and 77°c with a velocity of 50 m/s and exits at 85 kpa and 320 m/s. the heat losses from the nozzle to the surrounding medium at 20°c are estimated to be 3.2 kj/kg. determine (a) the exit temperature and (b) the total entropy change for this process. solve this problem using constant specific heats.
Answers: 1
image
Engineering, 06.07.2019 03:20, demotte79991
What is the maximum height from which a mass of 30 kg can fall on to a flange on the lower end of a vertical rod of length 1.0 m and diameter 20 mm, the upper end being rigidly fixed, if the stress in the rod is not to exceed 80 mpa? the tensile modulus of the rod is 200 gpa.
Answers: 3
Do you know the correct answer?
A classic use of a stack if for checking whether an expression that contains a set of different kind...

Questions in other subjects: