Complete the sentences by filling in the blanks. Each correct answer earns points!
Before learning a data structure, start with , which means understanding why it is used and what problem it solves.
Context: Purpose-first learning (Why this data structure?)
A is a collection of elements where the last inserted element is the first one removed (LIFO).
Context: Stack definition and LIFO rule
The rule that describes stack removal order is called : the most recently added element is removed first.
Context: LIFO meaning
In a stack, the (last in) is the most recently inserted element and is the first candidate for removal.
Context: Top (Last In) concept
Because of LIFO, the stack has a : only the most recently added element can be removed efficiently.
Context: Stack operation constraint (only top removed)
Attempting to remove a middle element in a stack leads to the effect that it is not directly possible without removing elements above it first, because only the can be removed first.
Context: Cause of middle removal difficulty (top-first rule)
Pressing the browser Back button can be modeled as , where pages behave like a stack and Back returns to the most recently visited page.
Context: Browser navigation as a stack model
Cause → Effect: Stack uses the LIFO rule (last inserted removed first) which causes the browser Back button to return to the most recently visited page .
Context: Cause→effect relationship: LIFO enables efficient Back
Cause → Effect: Using an array for browser history without enforcing LIFO behavior causes the system to perform to locate the correct page.
Context: Cause→effect: array without LIFO leads to inefficient search
In the array scenario described, to reach a target page like page 4, the system may search through earlier positions until it finds it.
Context: Understanding the array search behavior
In the stack scenario described, when Back is pressed, the system follows LIFO to remove the last inserted page (for example, P4) .
Context: Understanding direct removal under LIFO
A data structure can be viewed as : rules that govern how elements are added, accessed, and removed.
Context: Data structures as rules
Cause → Effect: A rule is explicitly set for the data structure (for example, LIFO) which causes operations to become consistent and faster for the intended use case because the system follows the rule to restrict which element can be removed/accessed next, leading to .
Context: Cause→effect: explicit rules enable consistent efficiency
The books analogy helps explain stack behavior: if you try to take a middle book, all the books around it will get messed up because you must remove the book first.
Context: Books analogy and top-first removal
When comparing array vs stack for browser back navigation, the key difference is that the stack directly follows , while the array approach may require searching to find the target page.
Context: Array vs stack comparison for the same use case