CBSE Class 12 Computer Science
Question 24 of 63
Data Structures in Python — Question 7
Back to all questions3
Reason — Initially, two opening parentheses '(' are pushed onto the stack. When a closing parenthesis ')' is encountered, it is matched with an open parenthesis on the stack. Subsequently, two new opening parentheses are pushed onto the stack. Then subsequent two closing parentheses are matched with open parentheses on the stack and this process repeats. ensuring that at most, 3 parentheses are on the stack at any given time, maintaining balance.