Question: Solve the problem using C++. Modifu the following code to complete the task. Create the main.cpp file by yourself. Stack.h #ifndef STACK_H #define STACK_H const
Solve the problem using C++. Modifu the following code to complete the task. Create the main.cpp file by yourself.
Stack.h
#ifndef STACK_H #define STACK_H
const int MAX_ITEMS = 5;
using namespace std; class FullStack{
}; class EmptyStack{
public: string thrown_from; int errorID;
};
template
private: int top; ItemType items[MAX_ITEMS];
public: Stack();
bool IsFull(); bool IsEmpty();
void MakeEmpty(); void Push(ItemType); void Pop(); ItemType Top();
};
#include "Stack.tpp" #endif
Stack.tpp
template
template
template
template
template
items[top+1] = item; top++; }
template
template

3. Use a stack to determine whether a string of parenthesis is balanced or not? If the string is not balanced, then print the longest substring that is balanced. If the length of the longest substring is less than 2, print Totally unbalanced. Test case 1: Input: () (((((() () () Output: () () () Test case 2: Input: 0 (0 ()) Output: Balanced Test case 3: Output: ) Output: Totally unbalanced
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
