Question: Need help with D in C++ please! infix2postfix.cpp #include stack.hpp using namespace std; // Auxiliary method, you probably find it useful // Operands are all

Need help with D in C++ please!

Need help with D in C++ please! infix2postfix.cpp #include "stack.hpp" using namespace

infix2postfix.cpp

#include "stack.hpp"

using namespace std;

// Auxiliary method, you probably find it useful // Operands are all lower case and upper case characters bool isOperand(char c){ return (c >= 'a' && c = 'A' && c

// Auxiliary method, you probably find it useful int precedence(char c) { if(c == '+' || c == '-'){ return 0; } if(c == '*' || c == '/'){ return 1; } if(c == '^'){ return 2; } return -1; }

int main(){ freopen("input_infix2postfix.txt", "r", stdin); string input; string solution; int line_counter = 0; while(cin >> solution){ cin >> input; Stack stack; string result;

//The input file is in the format "expected_solution infix_expression", //where expected_solution is the infix_expression in postfix format

for(int i=0; i

stack.hpp

//#include #include #include #include #include

// Ideally this would not be a huge number, you could also use a vector #define MAXSIZE 100000

using namespace std; template class Stack{ private: T arr[MAXSIZE]; // the actual stack int topIndex; // index of the top element public: Stack(){ topIndex = -1; // constructor }; ~Stack(){}; // destructor void push(T c); // push c to the list T pop(); // return and remove the top element in the stack T peek(); // return the top element in the stack int size(); // returns the size of the stack void display(); // display the stack in stdout };

input_infix2postfix.txt

ab+ a+b abcd^e-fgh*+^*+i- a+b*(c^d-e)^(f+g*h)-i ab+cd+* (a+b)*(c+d)

(b). (20points) Balancing parenthesis: Complete the balancing.cpp file based on the comments in the file. Specifically, complete the for loop as shown below to check whether s is balanced: 232425for(inti=0;i

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!