Questions: Stacks

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You are checking whether parentheses in the string '({[]})' are balanced using a stack. When you encounter a closing bracket ']', what is the correct next action?

APush ']' onto the stack so it can be matched later
BPop the top element from the stack and verify it is the matching opening bracket '['
CClear the stack and restart the scan from the current position
DSearch the stack from bottom to top for any '[' and remove it
Question 2 Multiple Choice

Function A calls function B, which calls function C. When C finishes and returns, which function resumes and why?

AFunction A resumes, because it initiated the call chain and is the 'root' caller
BFunction B resumes, because its frame was pushed most recently before C's call — LIFO order dictates it is popped first
CFunction A resumes, because the call stack always returns to the original caller after any return
DWhichever function the OS scheduler selects next
Question 3 True / False

A stack's LIFO constraint is a performance limitation compared to arrays, which allow access to any element at any index.

TTrue
FFalse
Question 4 True / False

When a recursive function calls itself too many times and the program crashes, this is a direct consequence of the LIFO call stack running out of allocated space.

TTrue
FFalse
Question 5 Short Answer

Why does LIFO ordering — rather than FIFO or random access — make stacks the natural data structure for tracking the state of recursive function calls?

Think about your answer, then reveal below.