Recall & Review
beginner
What is a stack in simple terms?
A stack is like a pile of plates where you can only add or remove the top plate. It follows Last In, First Out (LIFO) order.
Click to reveal answer
beginner
Why do we need a stack data structure?
Stacks help manage tasks where the last thing added must be done first, like undo actions or keeping track of function calls.
Click to reveal answer
beginner
How does a stack solve the problem of reversing data?
By pushing items onto the stack and then popping them off, the order reverses because the last item added comes out first.
Click to reveal answer
beginner
What real-life example is similar to how a stack works?
A stack of books where you add or remove only the top book is like a stack data structure.
Click to reveal answer
beginner
Name a common programming problem where stacks are used.
Stacks are used in checking balanced parentheses in expressions, like making sure every '(' has a matching ')'.
Click to reveal answer
What order does a stack follow?
✗ Incorrect
Stacks follow Last In, First Out (LIFO), meaning the last item added is the first to be removed.
Which of these is a problem stacks help solve?
✗ Incorrect
Stacks help with undo actions because the last action done is the first to be undone.
If you push 1, then 2, then 3 onto a stack, what will be popped first?
✗ Incorrect
3 is popped first because it was the last item pushed onto the stack.
Which real-life object is NOT like a stack?
✗ Incorrect
A queue follows First In, First Out (FIFO), unlike a stack which is LIFO.
What problem does a stack solve in function calls?
✗ Incorrect
Stacks keep track of function calls so the program knows which function to return to after finishing the current one.
Explain why a stack is useful in programming and give two examples of problems it solves.
Think about tasks where the last thing done must be undone or finished first.
You got /4 concepts.
Describe how a stack can reverse the order of items and relate it to a real-life example.
Imagine adding items on top and removing them from the top.
You got /4 concepts.