Question: You are given a string consisting of parenthesis style characters () [] and {3. A string of this type is said to be correct if:

 You are given a string consisting of parenthesis style characters ()[] and {3. A string of this type is said to becorrect if: (a) It is an empty string (b) If string A

You are given a string consisting of parenthesis style characters () [] and {3. A string of this type is said to be correct if: (a) It is an empty string (b) If string A is correct and string B is correct then string AB is correct (c) If A is correct then (A), [A] and (A) are all correct. You are to write a program that takes as input from the keyboard a series of strings of this type that can be of any length. The first line of input will contain a single integer n telling you how many strings you will be testing. Following that integer will be n lines (each ending in a new line character) that represent the strings you are supposed to test with one string per line. Your program should output Yes if a given string is correct and No otherwise. For example if the user types the following as input 3 Then vour program should give the following output: Yes No Yes You will note that if you do your program correctly there is no prompt for data and the yes and no answers will be interspersed with your input data when you enter it manually. The following would be a more accurate representation of what you see on the screen when you cut and paste the input into your program You are given a string consisting of parenthesis style characters () [] and {3. A string of this type is said to be correct if: (a) It is an empty string (b) If string A is correct and string B is correct then string AB is correct (c) If A is correct then (A), [A] and (A) are all correct. You are to write a program that takes as input from the keyboard a series of strings of this type that can be of any length. The first line of input will contain a single integer n telling you how many strings you will be testing. Following that integer will be n lines (each ending in a new line character) that represent the strings you are supposed to test with one string per line. Your program should output Yes if a given string is correct and No otherwise. For example if the user types the following as input 3 Then vour program should give the following output: Yes No Yes You will note that if you do your program correctly there is no prompt for data and the yes and no answers will be interspersed with your input data when you enter it manually. The following would be a more accurate representation of what you see on the screen when you cut and paste the input into your program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!