design a balancedstring class having 2 members string str and a counter.the default constructor of balancedstring initializes str to the empty and resets counter to zero.the class's one-argument constructor passes a strings to str and resets counter to zero.the balancedstring class also provide a boolean method boolean balanced() that returs true if a stringcontains a blanced set of parentheses.
for example:
the string "((hello)(goodbye))" has balanced parentheses , but "((a)(b)(0)" does not. A string with no parentheses is balanced.
To check whether or not a string contains a balanced set of parentheses
scan the string, left or right
if a character is left parentheses ,increment the counter and
if a character is right parentheses, decrement the counter
A string is balanced if the final counter value equals(),and while scanning the string, the value of the counter is never negative.
please send the answer quicklz
1
Expert's answer
2019-06-27T08:03:45-0400
Dear sibtain, your question requires a lot of work, which neither of our experts is ready to perform for free. We advise you to convert it to a fully qualified order and we will try to help you. Please click the link below to proceed: Submit order
Comments
Please help me i need the code of this program
Leave a comment