Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the given pseudocode to check if different types of braces, such as { }, ( ), [ ], match correspondently in order. And write

Modify the given pseudocode to check if different types of braces, such as { }, ( ), [ ], match correspondently in order. And write an enhanced function checkAllTypeBraces(aString: string) in C++, including a main() function to test it.

// Checks the string aString to verify that braces match.

// Returns true if aString contains matching braces, false otherwise.

checkBraces(aString: string): boolean {

aStack = a new empty stack

balancedSoFar = true

i = 0

// Tracks character position in string

while (balancedSoFar and i < length of aString)

{ ch = character at position i in aString

i++

// Push an open brace

if (ch is a '{')

aStack.push('{')

// Close brace

else if (ch is a '}')

{ if (!aStack.isEmpty())

aStack.pop()

// Pop a matching open brace

else

// No matching open brace

balancedSoFar = false

} // Ignore all characters other than braces

} if (balancedSoFar and aStack.isEmpty())

aString has balanced braces

else

aString does not have balanced braces

}

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

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

=+Is the sex relevant to the issue?

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago