Consolidated Question Patterns & Abstractions: Computational Thinking (Weeks 1-4)
This document synthesizes the core problem types and mental algorithms for the first four weeks of Computational Thinking. Use this to rapidly identify what a question is asking and which tools you need to solve it.
📚 Table of Contents
- Week 1: Procedural Thinking & Basic Operations
- Week 2: Advanced Logic & Finding Extrema
- Week 3: Procedures & Boolean Flags
- Week 4: Nested Loops & All-Pairs Comparisons
Week 1: Procedural Thinking & Basic Operations
- Core Idea: Learning to read and write simple, step-by-step instructions (procedures) using the card-pile model. Focus is on counting, summing, and averaging.
| Pattern # | Pattern Name | Frequency | Difficulty | Core Skill & Abstraction |
|---|---|---|---|---|
| 1.1 | Procedure Interpretation | High | Easy | Abstract: Identify what each variable does. Is it a Counter (+1) or an Accumulator (+ value)? A final Sum / Count step means it’s calculating an Average. |
| 1.2 | Bug Identification | Medium | Easy-Medium | Abstract: The most common bug is an incorrect loop instruction. Trace the repeat from Step N line. Does it incorrectly go back to an Initialize step, resetting the variables? |
| 1.3 | Procedure Tracing (Execution) | High | Medium | Abstract: Become the computer. Create a “scratchpad” for your variables. Process one card at a time, updating the values on your scratchpad exactly as the instructions say. |
| 1.4 | Data Sanity Checks | Low | Easy | Abstract: Check two things: 1. Data Type (is a number written as text?). 2. Value Validity (is a count negative? is a name a number?). |
đź§ Week 1 Mental Algorithm: The Basic Loop
When you see a simple procedure that iterates through one pile of cards:
- Triage: It’s a basic loop for counting, summing, or averaging.
- Abstract & Act:
- Find the
Initializestep. This tells you the purpose of the variables. - Find the
Ifstatement. This is the filter that decides which cards to process. - Find the update step. This is the action (counting or summing).
- Check the
repeat fromstep. Make sure it doesn’t reset your work. - Check for a final calculation (like
A / B).
- Find the
Week 2: Advanced Logic & Finding Extrema
- Core Idea: Using procedures to find the “best” card (minimum or maximum) and applying more complex conditional logic.
| Pattern # | Pattern Name | Frequency | Difficulty | Core Skill & Abstraction |
|---|---|---|---|---|
| 2.1 | Finding Minimum/Maximum | High | Easy | Abstract: Recognize the “King of the Hill” pattern. A variable is updated only if a new card’s value is better (greater for max, smaller for min). Check the initialization value (0 for max, a large number for min). |
| 2.2 | Interpreting Compound Conditions | High | Medium | Abstract: Translate the pseudocode into an English sentence. A - B often means “Count of items with Property A that do not also have Property B”. If A and B counts the overlap. |
| 2.3 | State Management & Re-initialization | Low | Hard | Abstract: Spotting a variable being reset inside a loop is the key. This means the procedure is processing data in groups (e.g., sentences, shopping trips) and the reset marks the boundary between groups. |
đź§ Week 2 Mental Algorithm: The Min/Max Pattern
When you see a procedure that compares a variable to a value on a card and updates itself:
- Triage: It’s a min/max finding problem.
- Abstract & Act:
- Check the
Initializevalue: Is it0or a very large number? This hints at max or min. - Check the
Ifcondition:If NewValue > ChampionValueFinding Maximum.If NewValue < ChampionValueFinding Minimum.
- Check the
Week 3: Procedures & Boolean Flags
- Core Idea: Organizing code into reusable blocks (procedures) and using
True/Falseflags to track complex states.
| Pattern # | Pattern Name | Frequency | Difficulty | Core Skill & Abstraction |
|---|---|---|---|---|
| 3.1 | Boolean Logic with Flags | High | Medium | Abstract: Recognize the two main patterns for flags: 1. “For All” Check: Initialize flag = True, then set to False if you find a single failure. 2. “At Least One” Check: Initialize flag = False, then set to True if you find a single success. |
| 3.2 | Using Procedures (Subroutines) | High | Medium-Hard | Abstract: Trace the main procedure. When you see a Call Procedure(Input), pause, “run” the subroutine with that specific Input, get its Return value, and substitute it back into the main procedure. |
| 3.3 | Interpreting Complex Nested Conditions | Medium | Medium | Abstract: Read the If/Else statements from the inside out. Determine the most specific condition first, then work your way up to understand what each branch of the logic is counting. |
đź§ Week 3 Mental Algorithm: The Boolean Flag
When you see a variable being set to True or False:
- Triage: This is a flag problem, likely checking for “all” or “at least one”.
- Abstract & Act:
Initialize to True: The procedure is optimistic. It’s trying to prove a statement like “All items have this property”. It will only becomeFalseif a counterexample is found.Initialize to False: The procedure is pessimistic. It’s trying to prove “At least one item has this property”. It will only becomeTrueif an example is found.
Week 4: Nested Loops & All-Pairs Comparisons
- Core Idea: Mastering the “all-pairs” comparison pattern, which is essential for finding duplicates, pairs, and relationships between individual data points.
| Pattern # | Pattern Name | Frequency | Difficulty | Core Skill & Abstraction |
|---|---|---|---|---|
| 4.1 | All-Pairs Comparison (Nested Loops) | High | Hard | Abstract: Recognize the three-pile structure. The inner loop (While Pile 2 is not empty) is where the action is: it compares the current card X from the outer loop to every previously seen card Y in Pile 2. |
| 4.2 | Nested Logic on a Single Card | High | Medium | Abstract: Differentiate this from the above. Here, the inner loop iterates over the attributes of a single card (e.g., the letters in a word). It answers a question about that one card only. |
| 4.3 | Distinguishing Single vs. Nested Loops | High | Medium | Abstract: The core question is: am I comparing each card to a fixed standard (e.g., class average) or to every other card? The first is a single loop; the second requires a nested loop. |
đź§ Week 4 Mental Algorithm: The Nested Loop
When you see a procedure with three piles and loops within loops:
- Triage: This is an All-Pairs Comparison. The goal is to check every possible pair of cards.
- Abstract & Act:
- Identify the card from the outer loop (
X) and the card from the inner loop (Y). - Go to the
Ifstatement inside the inner loop. This is the core logic. - Translate that
Ifstatement into a plain English sentence describing the property of a valid pair. For example:If X.Country == Y.Country AND X.Medal != Y.Medaltranslates to “a pair of players from the same country who won different medals”. - The final result is the total count of such pairs.
- Identify the card from the outer loop (