Question: The expressionConverter cpp file needs to be filled out only // expressionConverter.h #pragma once #include #include using namespace std; class ArithNode { public: bool isOperator;

The expressionConverter cpp file needs to be filled out only
// expressionConverter.h
#pragma once #include
using namespace std;
class ArithNode { public: bool isOperator; char binaryOperator; // set only if isOperator = true int operand; // set only if isOperator = false ArithNode *left; ArithNode *right;
ArithNode(char op) { left = NULL; right = NULL; binaryOperator = op; isOperator = true; }
ArithNode(int n) { left = NULL; right = NULL; operand = n; isOperator = false; }
};
string Infix2RPN(string); string RPN2Infix(string); ArithNode *Infix2ExpressionTree(string); ArithNode *RPN2ExpressionTree(string); int EvaluateInfix(string); int EvaluateRPN(string); =================================================================================== // expressionConverter.cpp
#include "ExpressionConverter.h"
// This part needs to be filled out
==================================================================================== // main.cpp
#include
#include "ExpressionConverter.h"
////////////////////////////////////////////////////////////////////////////////////////////// // DO NOT EDIT THIS FILE (except for your own testing) // CODE WILL BE GRADED USING A MAIN FUNCTION SIMILAR TO THIS //////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
template
int main() {
// Convert and evaluate infix expression { string infix = "10 * ( 20 + 30 )"; cout
if (passedAllTests) cout
template string removeWhitespace(const string &s) { string t; for (int i = 0; i bool testString(const string &nameOfTest, const string &received, const string &expected) { if (removeWhitespace(received) == removeWhitespace(expected)) { cout string tree2string(const ArithNode *ptr) { if (ptr == nullptr) return ""; string s; if (ptr->isOperator) s = string(1, ptr->binaryOperator) + "(" + tree2string(ptr->left) + ")" + "(" + tree2string(ptr->right) + ")"; else s = to_string(ptr->operand); return s; } bool testTree(const string &nameOfTest, const ArithNode *ptr, const string &expected) { string received = tree2string(ptr); if (received == expected) { cout void printTree(ArithNode *ptr, string prefix, bool isTail) { if (!ptr->isOperator) { cout " : "> ") operand " : "> ") binaryOperator left, prefix + (isTail ? " " : "=> "), false); printTree(ptr->right, prefix + (isTail ? " " : "=> "), true); } void printTree(ArithNode *ptr) { printTree(ptr, "", true); } ========================================================================================================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
