100+ Balanced Parenthesis Question and Answer with FREE PDF

Created by livemcqs team of experts in their respective subject, Balanced Parenthesis Question and Answer provide you with verified, comprehensive questions and answers that cover each topic in detail. They contain all the information that you need to pass both online and offline. These Balanced Parenthesis Question and Answer will help you prepare for any exam including BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.

Balanced Parenthesis Question and Answer

1. What is the time complexity of balancing parentheses algorithm?

a) O (N)

b) O (N log N)

c) O (M log N)

d) O (N2)

Answer: O (N)

2. Which application of stack is used to ensure that the pair of parentheses is properly nested?

a) Balancing symbols

b) Reversing a stack

c) Conversion of an infix to postfix expression

d) Conversion of an infix to prefix expression

Answer: Balancing symbols

3. In balancing parentheses algorithm, the string is read from?

a) right to left

b) left to right

c) center to right

d) center to left

Answer: left to right

4. Which is the most appropriate data structure for applying balancing of symbols algorithm?

a) stack

b) queue

c) tree

d) graph

Answer: stack

5. Which of the following does the balancing symbols algorithm include?

a) balancing double quotes

b) balancing single quotes

c) balancing operators and brackets

d) balancing parentheses, brackets and braces

Answer: balancing parentheses, brackets and braces

6. Which of the following statement is incorrect with respect to balancing symbols algorithm?

a) {[()]}

b) ([ )]

c) {( )}

d) { [ ] }

Answer: ([ )]

7. What should be done when an opening parentheses is read in a balancing symbols algorithm?

a) push it on to the stack

b) throw an error

c) ignore the parentheses

d) pop the stack

Answer: push it on to the stack

8. When the corresponding end bracket/braces/parentheses is not found, what happens?

a) The stack is popped

b) Ignore the parentheses

c) An error is reported

d) It is treated as an exception

Answer: An error is reported

9. If the corresponding end bracket/braces/parentheses is encountered, which of the following is done?

a) push it on to the stack

b) pop the stack

c) throw an error

d) treated as an exception

Answer: pop the stack

10. How many passes does the balancing symbols algorithm makes through the input?

a) one

b) two

c) three

d) four

Answer: one

Download PDF (Balanced Parenthesis Question and Answer)

2 thoughts on “100+ Balanced Parenthesis Question and Answer with FREE PDF”

Comments