Recall & Review
beginner Click to reveal answer
What does the push operation do in a stack?
The push operation adds a new element to the top of the stack, increasing its size by one.
beginner Click to reveal answer
In a stack, which end is used for the push operation?
The push operation always adds the element at the top end of the stack.
intermediate Click to reveal answer
What happens if you try to push an element onto a full stack (stack overflow)?
If the stack has a fixed size and is full, pushing another element causes a stack overflow error, meaning no more elements can be added.
beginner Click to reveal answer
Show the state of the stack after pushing elements 5, then 10, then 15.
Stack from top to bottom: 15 -> 10 -> 5 -> null
beginner Click to reveal answer
Why is the push operation considered LIFO in stacks?
Because the last element pushed onto the stack is the first one to be removed, following the Last In, First Out (LIFO) principle.
What does the push operation do in a stack?
✗ Incorrect
Push adds an element to the top of the stack.
If a stack is empty, what happens when you push an element?
✗ Incorrect
Pushing on an empty stack adds the element as the top (and only) element.
What is the order of elements after pushing 1, then 2, then 3 onto a stack?
✗ Incorrect
The last pushed element (3) is on top, so the order is 3 -> 2 -> 1 -> null.
What error occurs if you push onto a full stack?
✗ Incorrect
Pushing onto a full stack causes a stack overflow error.
Which principle does the push operation follow in a stack?
✗ Incorrect
Stacks follow LIFO, so push adds to the top and pop removes from the top.
Explain the push operation on a stack and how it affects the stack's state.
Think about where the new element goes and what happens to the stack size.
You got /3 concepts.
Describe what happens when you push multiple elements onto an empty stack, step by step.
Visualize adding one element at a time on top.
You got /3 concepts.
