Correct Sequence of brackets is always of primary importance both for written programs and mathematical expressions. By correct sequence we mean that for every opening bracket there is a closing bracket. The problem is to write a program that takes a random sized (size max 15) input of brackets from user, as a string, and can validate the sequence for e.g.
{([]{()})} valid
{[]}(} invalid
[]{{{} invalid
(((}))) invalid
{{{}}}} invalid
guys pls help me out with this
desert564 0 Light Poster
Recommended Answers
Jump to Postimplement stack URGENT
Jump to PostHmm... Your solution is really a brute force. :P If you do it as stack-liked as quuba said, it would be much easier and shorter. Also, you would go through the string only once, not twice - one for the whole string and the other for the array you created. …
Jump to PostNot bad... but what do you do if there's something in the brackets?
(ie, what if there's a point to the program)That's not so bad - you can remove from front until you have a paren of some sort, and then remove from back until you have a …
Jump to PostHmm... You adopted monarchmk method which is not a stack-liked method. Do you know what 'stack' is? The stack-liked pseudo code should be as followed:
/* str <- a string which may be empty stack <- a stack-liked storage pos <- an integer of current position in …
All 13 Replies
quuba 81 Posting Pro
jon.kiparsky commented: Good answer. +2
monarchmk 24 Junior Poster in Training
jon.kiparsky commented: If rep matters to you, quit doing people's homework for them. +0
jon.kiparsky 326 Posting Virtuoso
monarchmk 24 Junior Poster in Training
Taywin 312 Posting Virtuoso
desert564 0 Light Poster
jon.kiparsky 326 Posting Virtuoso
desert564 0 Light Poster
Taywin 312 Posting Virtuoso
desert564 0 Light Poster
jon.kiparsky 326 Posting Virtuoso
monarchmk 24 Junior Poster in Training
jon.kiparsky 326 Posting Virtuoso
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.