Lab 04 - Stack Vs Queue
Lab 04 - Stack Vs Queue
1. Your tasks
The initial code for this lab provide you a skeleton to implement the following functions. Your tasks
are to complete these functions to make them work.
Problem 1.
Complete bool checkParentheses(char* arr) function that check a sequences of parentheses is
valid or not. Parentheses include regular parentheses (), square brackets [], and braces {}.
Example
char s1[] = "{(())}[]";
cout << checkParentheses(s1) << endl; // Output: 1 (Valid)
char s2[] = "({)}[]";
cout << checkParentheses(s2) << endl; // Output: 0 (Invalid)
Problem 2.
Complete int evaluatePostfixExpression(char* exp) function that return the result of the
postfix expression in exp. Note that the input expression only contains addition, subtraction,
multiplication, division on single digit numbers (operands).
Example:
Problem 3.
Complete int evaluatePrefixExpression(char* exp) function that return the result of the
prefix expression in exp. Note that the input expression only contains addition, subtraction,
multiplication, division on single digit numbers (operands).
Example: