Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ How to Check if Expressions are Similar I have the two given files: a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) (newline) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b (newline)

C++ How to Check if Expressions are Similar

I have the two given files:

image text in transcribed

a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B)

(newline)

a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b (newline)

Expected Output (Is Similar):

"Yes"

image text in transcribed

A+B+5+6+a A-B+5+6+a

(newline)

Expected Output (Is NOT Similar)

"No"

How can the code be written so that it checks that every expression within the file is similar to each other?

If every expression is similar, it simply outputs "Yes", otherwise, there exists an expression that is not similar and only outputs "No"

I'm able to check if the file has balanced brackets, but I'm not sure how to go about checking that they're similar?

Thanks

EDIT: I'm thinking I should convert every expression to postfix but I'm not sure on the implementation of that either.

a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b A+B+5+6+a A-B+5+6+a a+B-A-1+3+b a+B-A+0+2+b +(a+b-A-1+3+B) a+b-(A+1)+3+B a+b-(A+1)-(-3-B) a+(b-(A+1)+3+B) a+{(b-[A+1])+3+B} a+b-A+2+B a+B-A+1+1+b A+B+5+6+a A-B+5+6+a

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_2

Step: 3

blur-text-image_3

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

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

What does this key public know about this issue?

Answered: 1 week ago

Question

What is the nature and type of each key public?

Answered: 1 week ago

Question

What does this public need on this issue?

Answered: 1 week ago