Back to Topic 6.2 — Data structures
6.2.3Computer Science SL5 flashcards

Stacks (LIFO)

Practice Flashcards

Flip to reveal answers
Card 1 of 56.2.3
6.2.3
Question

What is a stack?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All 5 Flashcards — Stacks (LIFO)

Sign up free to track progress and get spaced-repetition review schedules.

Card 1definition

Question

What is a stack?

Answer

A structure that allows adding and removing at one end only, the top. The last item put in is the first taken out — last in, first out, or LIFO.

Card 2definition

Question

What are the four stack operations?

Answer

push adds an item on top; pop removes the top item and returns it; peek returns the top item without removing it; isEmpty says whether there is anything in the stack at all.

Card 3concept

Question

Why are all stack operations O(1)?

Answer

Every operation touches only the top. Nothing is shifted along and nothing is searched for, so the cost is the same whether the stack holds three items or three million.

Card 4example

Question

Give three uses of a stack.

Answer

Undo, where the most recent action must be reversed first; the call stack, since function calls unwind in reverse order; and checking that brackets match, because the most recent opening bracket must close first.

Card 5concept

Question

What causes a stack overflow?

Answer

A stack that keeps growing with nothing being popped until it runs out of memory — usually a function that calls itself with no way to stop.

Track your progress with spaced repetition

Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.

Start Free
IB Computer Science Stacks (LIFO) Flashcards | 6.2.3 | Aimnova