Skip to content

Commit 39018be

Browse files
author
Brian Elinsky
committed
Fix Dutch National Flag flashcards to match book solution and clarify stack optimization question
1 parent dfbce87 commit 39018be

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

problem-questions/05_arrays/5.01_dutch_national_flag/01_what_each_pointer_represents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
**A:**
66
- `smaller`: first position of middle region (= pivot)
77
- `equal`: first unprocessed element
8-
- `larger`: last unprocessed element (NOT first position of top region)
8+
- `larger`: first position of top region (boundary after unprocessed)

problem-questions/05_arrays/5.01_dutch_national_flag/02_initialize_pointers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
**A:**
66
- `smaller = 0` (middle region starts empty at beginning)
77
- `equal = 0` (first element is unprocessed)
8-
- `larger = len(A) - 1` (last index, top region built from right)
8+
- `larger = len(A)` (top region starts empty, built from right)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Optimization Strategy for Slow Operations
22

3-
**Q:** When a data structure operation is too slow (e.g., O(n) max lookup), what's the first optimization strategy?
3+
**Q:** When augmenting a data structure with a new operation that would otherwise be slow (e.g., O(n) max on a stack), what's the key strategy?
44

55
**A:** Cache/precompute the result using auxiliary space. Trade space for time.
6+
7+
Note: This applies when you're constrained to a particular data structure but need to add an operation. If you can change the data structure entirely, consider using a more suitable one instead.

0 commit comments

Comments
 (0)