0% found this document useful (0 votes)
0 views1 page

Asgn 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views1 page

Asgn 2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS221- Data Structures & Algos, Fall 2024, Assignment # 2

Due Date: October 10, 2024 (10 am) Total Marks: 50

Question (50 Marks) A lack of a certain symbol (such as a missing brace or bracket or parenthesis) will cause
the compiler to spill out a hundred lines of diagnostics without identifying the real error. The solution is to
check whether every bracket, braces or parentheses is balanced. Every right brace, bracket, parenthesis and
etc must correspond to its left counter part. Develop a stack using C++ which is given a set of string statement
as follows:

String statement = (a + b * c) / [(a – b) ^ c]

The code should read each character in the string. If the character is a variable name or an operator (like +,
-, * or /), then it should do nothing. If the character read is an opening symbol like ( or { or [, then it should
push it on stack. If the character read is a closing symbol like ] or } or ), then it should pop from stack. In the
end if the stack is not empty, display a message that the statement is not balanced in terms of symbols.

For more explanation: see slides 16, 17, 18, 19 and 20 of Week 5. Ppt

Page 1 out of 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy