i am new here and i have this Q to solve it plz help me
Using class stack, write a program to read an expression and checks if the symbols : the parentheses ( ), square brackets [ ] are balanced or not. For example :
(a+b-[c+d)] is not balanced correctly.
(a+b-[c+d]) is balanced
:cry:
moon_light
0
Newbie Poster
Recommended Answers
Jump to PostHi,
Assuming you already have a stack class implemented. Start with an empty stack and just read your string char by char if it is a "(" or "[" push that char to your stack; if it is a ")" or "]" pop a char from your stack and …
Jump to PostThat's easy. Stacks are FILO so if you pop a parenthesis off, then at the oppposite position (the last) would have to be a parenthesis. Show a little effort and I can help more.
Jump to Postthank u for ur replayies,,,,
i've already write the stack class ,but i am confusing in writing the code i need someone who explain how to write it because i don't know how to write it,,,plzLet me see your stack class
All 9 Replies
Lord Soth
4
Posting Whiz in Training
server_crash
64
Postaholic
moon_light
0
Newbie Poster
iamthwee
moon_light
0
Newbie Poster
moon_light
0
Newbie Poster
AstroNox
0
Junior Poster in Training
moon_light
0
Newbie Poster
iamthwee
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.