When a closing bracket appears, what must happen?

Practice this question from Valid Parentheses - Stack matching Pattern Practice Quiz, with options and an explanation.

Question

When a closing bracket appears, what must happen?

Option A — Correct answer

The stack top must match the closing bracket

Option B

Push the closing bracket always

Option C

Ignore the bracket type

Option D

Clear the whole stack

Explanation

The stack top must be the matching opening bracket.

Valid Parentheses - Stack matching Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker