Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a stack class MATCH that gets a string from the user and uses a pointer-based stack to determine whether its parentheses are properly balanced/matched.

Write a stack class MATCH that gets a string from the user and uses a pointer-based stack to determine whether its parentheses are properly balanced/matched. For example, your program should print true for [()]{}{[()()]()} and false for [(]). Size of character in the strings of parentheses is less than 50. The valid chars are [,],{,},(,),<, and >. The strings of parentheses should not have space char. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions