Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

14: Balanced Parenthese A string of characters has balanced parentheses ifeach r

ID: 3617983 • Letter: 1

Question

14: Balanced Parenthese   A string of characters has balanced parentheses ifeach right parenthese occuring in a string is matched with apreceding left parenthesis, in the same way that each right bracein a C++ program is matched with a preceding left brace. Write aprogram that uses a stack to determine whether a string entered atthe keyboard has balenced parenteses. Here are some hints on how the program flows: Checks tosee if a string has balanced parenthesis. Stack each leftparenthesis as it is found, and then pop it off the stack whenits mate is encountered. The string is not balanced if uponencountering a right parenthesis, the top of the stack is nota left parenthesis, or if we get to the end of the string andthe stack is not empty 14: Balanced Parenthese   A string of characters has balanced parentheses ifeach right parenthese occuring in a string is matched with apreceding left parenthesis, in the same way that each right bracein a C++ program is matched with a preceding left brace. Write aprogram that uses a stack to determine whether a string entered atthe keyboard has balenced parenteses. Here are some hints on how the program flows: Checks tosee if a string has balanced parenthesis. Stack each leftparenthesis as it is found, and then pop it off the stack whenits mate is encountered. The string is not balanced if uponencountering a right parenthesis, the top of the stack is nota left parenthesis, or if we get to the end of the string andthe stack is not empty

Explanation / Answer

please rate - thanks #include using namespace std; char pop(char[], int& ); void push(char[],int&,int, char) ; int main() { int n=0,i=0,j,maxsize=20; char stack[maxsize],m=' '; char delimin[3]={'{','(','['}; char delimout[3]={'}',')',']'}; string input; coutinput; while(input[i]!=''&&m!='z') {//cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote