The increment and decrement method wont work correctly for all cases.... Ex:- ))a+b(( This is not a well formed parenthesis... But satisfies the algorithm. The better way is to use a stack... When u find a ' ( ' push it into the stack and when u find a ' )' pop off the top element. Finally the stack should be empty. If [stack has one or more ' ( ' ] or [the stack is empty and exp is not empty] then it is not a well formed parenthesis...
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
