Question: Develop a stack class that asks users to enter a string from command line and uses a linked list based stack to determine whether parentheses

Develop a stack class that asks users to enter a string from command line and uses a linked list based stack to determine whether parentheses in the string are properly balanced/matched. For example, your program should print true for [()]{}{[()()]()} and false for [(]). Size of character in the strings of parentheses should be less than 50. The valid chars are [,],{,},(,),<, and >. The strings of parentheses should not have space character. For this programs you can base StackwLL_TBC.cpp file we developed in the class.

Note that this problem is simplified version of Expression Evaluation problem (pg. 128 and 129), where two stacks are used for operators and operand. However, this particular case does not deal with operations; therefore, only one stack is used. A solutions would push() an opening bracket into stack and pop() it once corresponding closing bracket.

A few examples are given below.

>Enter a string: [()]{}{[()()]()}

>True

>Enter a string: [()]

>True

>Enter a string: [)(]

>False

>Enter a string: ((())

>False

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!