Question: I can't figure out how to do the isbalanced method. I feel like I'm on the right track. I can't get it to work with

 I can't figure out how to do the isbalanced method. Ifeel like I'm on the right track. I can't get it to

I can't figure out how to do the isbalanced method. I feel like I'm on the right track. I can't get it to work with run all test. Could anyone help?

12 references public static class ParenthesisMatcher ///

/// checks to see if open or close parenthesis and puts in stack. If close parenthesis match then takes it out of the stack. if even then returns true otherwise false /// /// string /// 12 references @ 1/12 passing public static bool IsBalanced (string s) Stack vs = new Stack(); foreach (char i in s) if (s[i] == '{' || s[i] == 'C' || s[i] == '[') { vs. Push(s[i]); if (s[i] == '}' || s[i] == ')' || s[i] == '1') if (vs.Count == 0) return false; } else if (!Matches(vs.Pop(), s[i])) vs.Pop(); return false; else return false; if (vs.Count == 0) return true; else return false; /// /// Determines whether the piven character is an onenine narenthesis. /// /// Determines whether the given character is an opening parenthesis. /// /// The character to check. /// Whether c is an opening parenthesis. private static bool IsOpeningParenthesis(char c) { return c == 'C' || II/ Determines whether the given character is a closing parenthesis. /// /// The character to check. /// Whether c is a closing parenthesis. O references private static bool IsclosingParenthesis(char c) { ')' || c == 'l' || c == '}'; } return C == /// /// Determines whether the given characters form a matched pair /// of parentheses. /// /// The opening character. /// The closing character. /// Whether a and b form a matched pair of parentheses. 1 reference private static bool Matches (char a, char b) { return (a 'C' && b '') || (a == '' && b == '1') || (a == '{' && b == "}')

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!