Check for Balanced Parentheses using Stack?



Check for Balanced Parentheses using Stack?..

Answer / hrpynux@gmail.com

If the current character is a starting bracket ('(' or '{' or '[') then push it to stack. If the current character is a closing bracket (')' or '}' or ']') then pop from stack and if the popped character is the matching starting bracket then fine else brackets are not balanced.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is the function to call to turn an ascii string into a long?

0 Answers  


How would you represent an error detected during constructor of an object?

1 Answers  


What are the stages in the development cycle?

0 Answers  


what is the behaviour of C and C++ compiler for the below statements. int *p; p = malloc(100); Is the behaviour same ? or different ?

2 Answers  


Where must the declaration of a friend function appear?

0 Answers  






What is the difference between passing by reference and passing a reference?

0 Answers  


How many storage classes are available in C++?

1 Answers  


Write a program which uses Command Line Arguments

0 Answers  


Under what conditions is multiple inheritance not recommended?

1 Answers  


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

0 Answers  


What are the advantages of c++?

0 Answers  


Difference between pointer to constant vs. Pointer constant

0 Answers  


Categories