Implement a stack and solutions to the following problems: balancing parenthesis, evaluating postfix expressions and transforming infix expressions into postfix expressions. We are providing some sample code and input files: public/ balancing.cpp - main method to check whether an expression is balanced infix2postfix.cpp - main method to transform an infix expression into postfix input_balanced.txt - test cases for balancing.cpp input_infix2postfix.txt - test cases for infixtopostfix.cpp input_postfixEval.txt - test cases for postfixEval.cpp postfixEval.cpp - main method to evaluate postfix expressions stack.cpp - stack implementation stack.hpp - stack header file • To compile, run $ g++ stack.cpp balancing.cpp $ g++ stack.cpp postfixEval.cpp $ g++ stack.cpp infixtopostfix.cpp • To run each program, run $ ./a.out • The test cases follow this format: expected_solution input. Given input, your job is to implement code that gets the expected_solution. Obviously, you need to calculate expected_solution, not just print it. • balancing.cpp must balance round parentheses, and square and curly brackets (() [] {}) • While we provide a few test cases, you are expected to add more to make sure your code works. Note: in postfixEval, we just consider each single digital is an input number. For example, “65-” means the two operands are “6” and “5”, NOT “65”. what should the code be for the balancing.cpp
Implement a stack and solutions to the following problems: balancing parenthesis, evaluating postfix expressions and transforming infix expressions into postfix expressions.
We are providing some sample code and input files:
public/
balancing.cpp
- main method to check whether an expression is balanced
infix2postfix.cpp
- main method to transform an infix expression into postfix
input_balanced.txt
- test cases for balancing.cpp
input_infix2postfix.txt
- test cases for infixtopostfix.cpp
input_postfixEval.txt
- test cases for postfixEval.cpp
postfixEval.cpp
- main method to evaluate postfix expressions
stack.cpp
- stack implementation
stack.hpp
- stack header file
• To compile, run
$ g++ stack.cpp balancing.cpp
$ g++ stack.cpp postfixEval.cpp
$ g++ stack.cpp infixtopostfix.cpp
• To run each program, run
$ ./a.out
• The test cases follow this format: expected_solution input. Given input, your job is to implement code that gets the expected_solution. Obviously, you need to calculate expected_solution, not just print it.
• balancing.cpp must balance round parentheses, and square and curly brackets (() [] {})
• While we provide a few test cases, you are expected to add more to make sure your code works.
Note: in postfixEval, we just consider each single digital is an input number. For example, “65-” means the two operands are “6” and “5”, NOT “65”.
what should the code be for the balancing.cpp
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images