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
Which of the following ziegler nichols tuning methods the response of the controller to a step input should exhibit an s-shaped curve? a)-open loop mode b)-closed loop mode c)-both modes (open & closed) d)-none of the modes (open & closed)
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following controllers anticipates the future from the slope of errors over time? a)-proportional b)-on/off c)-integral d)-derivative.
Answers: 2
question
Engineering, 04.07.2019 18:10
What are the two (02) benefits, which may result from a successful implementation of preventive maintenance (pm) program in an organization? (clo3)a)- lean manufacturing b)-overlapping responsibilities c)-the planner is not qualified d)-accurate contractor information e)-reduction in equipment redundancies f)-accurate stores information
Answers: 3
question
Engineering, 04.07.2019 18:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
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
Mathematics, 20.11.2020 22:10
question
English, 20.11.2020 22:10
question
Mathematics, 20.11.2020 22:10
question
Mathematics, 20.11.2020 22:10
Questions on the website: 13722367