Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need assistance doing this In C++, Check to see if the symbols are balanced. instruction. The goal of this assignment is for you to
I need assistance doing this In C++, Check to see if the symbols are balanced.
instruction. The goal of this assignment is for you to write a program that checks a string of symbols to determine whether the symbols are balanced. For simplicity, your program will only need to consider the braces'',' and parentheses .. Examples of legal and illegal sequences are below: 00-legal (01 - illegal (0) - legal (01) - legal The following algorithm uses a stack data structure for its solution. Make an empty stack Read characters to end of line If the character is an opening symbol, push it onto the stack If the character is a closing symbol and the stack is empty, print an error message Otherwise, pop the stack If the symbol is not the corresponding opening symbol then report an error If you have reached the end of line and the stack is not empty, then report an error, else print legal Repeat until you reach the end file. The requirements of the assignment are: Your program should be implemented in either Cor C++. You are to implement your own stack functions, including push() and pop(). Your program should read its input from a file. You may assume that each line of the file will contain a string of symbols, and the number of characters in each string will not exceed 255. An easy way to implement a stack is to use an array and maintain an index to the top of the stack. You may initialize this index to -1 to indicate that the stack is empty Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started