Computational Thinking: Comprehensive Pattern Analysis & Solutions
Complete Qualifier Prep Guide - All 12 Weeks
Exam in 6 hours. Lock in. No distractions.
🎯 MASTER PATTERN CHEAT SHEET
Week 1-4: HIGH WEIGHT in Qualifier (80%+)
Pattern 1: Datasets You MUST Know
| Dataset | Columns |
|---|---|
| Words | Card#, Word, Part of Speech, Letter Count |
| Scores | Name, Subject, Marks, Gender, City, DOB |
| Library | Book, Author, Genre, Year, Language |
| Shopping Bills | Shop, Customer, Item, Price, Category |
| Olympics | Country, Gold, Silver, Bronze |
Pattern 2: The Standard Loop
Step 1: Arrange cards in Pile 1
Step 2: Initialize variables (A=0, B=0, etc.)
Step 3: If Pile 1 is empty, STOP and go to final step
Step 4: Read top card from Pile 1
Step 5: If <condition> then <action>
Step 6: Move card to Pile 2, repeat from Step 3
Step 7: Final output calculation
Pattern 3: Accumulator Patterns
| Pattern | Code | Use Case |
|---|---|---|
| Counter | A = A + 1 | Counting items |
| Accumulator | A = A + X.Value | Summing values |
| Average | Result = Sum / Count | A/B at end |
| Max Finder | if X > Max then Max = X | Finding maximum |
| Flag/Existence | A = 1 (NOT A = A+1) | “Did it exist?” |
Pattern 4: The “Reset Bug” Trap
Buggy: Repeat from Step 2 (where Step 2 sets count = 0)
Fixed: Repeat from Step 3 (check empty, not reinitialize)
Why It’s Wrong: Every iteration resets the counter to 0!
Logical Operators
Pattern 5: AND / OR / NOT
| Expression | True When… |
|---|---|
A and B | BOTH true |
A or B | AT LEAST ONE true |
not A | A is false |
Example:
if (Shop == "SV Stores" and Price > 500)
Only counts if BOTH conditions are met.
Pattern 6: De Morgan’s Laws
English:
- NOT (A and B) = (NOT A) or (NOT B)
- NOT (A or B) = (NOT A) and (NOT B)
Counter Types
Pattern 7: Simple Counter
count = count + 1
Increments by 1 each time condition is met.
Pattern 8: Distinct Counter (Flag Pattern)
if (Shop == "SV Stores") then A = 1
if (Shop == "Big Bazaar") then B = 1
if (Shop == "Sun General") then C = 1
X = A + B + C
Result = Number of distinct shops visited.
Key: Using = 1, NOT = A + 1.
Pattern 9: Comparison Counter
if (X.Value > Y.Value) then A = A + 1
if (X.Value == Y.Value) then B = B + 1
Counts pairs based on comparison.
Procedure Patterns
Pattern 10: Return True/False Procedures
procedure verifyPair(X, Y):
if (X.Genre != Y.Genre and X.Author == Y.Author):
return True
else:
return False
Pattern 11: Comparison Function
procedure compareSomething(A, B):
if A > B:
return -1
else:
return 1
Trap: Carefully note argument order (A, B) vs (B, A).
Data Sanity Checks
Pattern 12: Data Type Errors
| Column | Expected Type | Error Examples |
|---|---|---|
| Card Number | Integer | ”One”, “1.5”, text |
| Letter Count | Positive Integer | -5, 0, decimal |
| Part of Speech | Noun/Verb/etc. | ”Unknown”, number |
| Year | 4-digit Integer | ”Twenty Twenty”, 20.20 |
Pattern 13: Invalid Values
- Letter count cannot be negative or zero.
- Year cannot be in the future (if data is from past).
- Price cannot be negative.
Code Tracing Tips
Pattern 14: Manual Dry Run
- Draw a table with columns: Iteration, Card Data, Variable Values.
- Process one card at a time.
- Update ALL variables after each step.
Pattern 15: Nested IF = AND
if A:
if B:
action
Equivalent to: if (A and B): action
Week 5-8: Advanced Patterns
Pattern 16: Double Loop (Pairs)
for each X in Table 1:
for each Y in Table 2:
if (condition on X and Y):
count = count + 1
Note: This counts ALL pairs, including (A,B) and (B,A) separately.
Pattern 17: Same Author/Same Year
if (X.Author == Y.Author and X.Year == Y.Year):
...
Groups books by author-year combination.
Week 9-12: Flowcharts & Algorithms
Pattern 18: Flowchart Symbols
| Symbol | Meaning |
|---|---|
| Oval | Start/End |
| Rectangle | Process/Action |
| Diamond | Decision (Yes/No) |
| Parallelogram | Input/Output |
| Arrow | Flow direction |
Pattern 19: Searching Algorithms
- Linear Search: Check one by one. O(n).
- Binary Search: Requires sorted data. O(log n).
Pattern 20: Sorting Algorithms
- Bubble Sort: Compare adjacent, swap.
- Selection Sort: Find min, put at front.
- Insertion Sort: Insert into sorted portion.
🚨 TOP 10 EXAM TRAPS
- Reset Bug:
Repeat from Step 2when Step 2 initializes variables. - Count vs Flag:
A = A + 1(count) vsA = 1(existence). - Argument Order:
compare(A, B)vscompare(B, A)→ Different results! - AND vs OR:
A and Bis stricter thanA or B. - Nested IF: Same as AND, not OR.
- Pair Counting: (A,B) and (B,A) count as 2 pairs.
- Empty Pile Check: Must be at START of loop, not end.
- Data Types: “One” is NOT an integer.
- Letter Count Zero: Words MUST have ≥1 letter.
- Double Loop Output: If comparing pairs, watch for duplicates.
⚡ QUICK FORMULA REFERENCE
Average:
Counting: Increment by 1 when condition met.
Distinct Count: Use flags (0 or 1), sum at end.
Max/Min Finding:
Max = 0
for each X:
if X.Value > Max:
Max = X.Value
You got this, dawg. Time to execute. 🔥