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

Which sort is best for the set: 1 2 3 5 4 a) Quick Sort b) Bubble Sort c) Merge Sort

0 Answers  


You want to link a c++ program to c functions. How would you do it?

0 Answers  


Explain how to initialize a const member data.

0 Answers  


What is constructor in C++?

0 Answers  


What do you understand by a pure virtual member function?

0 Answers  


what is c++

0 Answers  


Which one is a preferred language C or C++? Why?

0 Answers  


What is an adaptor class or Wrapper class?

1 Answers  


What is an explicit constructor?

1 Answers  


What do you mean by early binding?

0 Answers  


What happens if a pointer is deleted twice?

0 Answers   Flextronics,


What are the important differences between c++ and java?

0 Answers  


Categories