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

DatasetColumns
WordsCard#, Word, Part of Speech, Letter Count
ScoresName, Subject, Marks, Gender, City, DOB
LibraryBook, Author, Genre, Year, Language
Shopping BillsShop, Customer, Item, Price, Category
OlympicsCountry, 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

PatternCodeUse Case
CounterA = A + 1Counting items
AccumulatorA = A + X.ValueSumming values
AverageResult = Sum / CountA/B at end
Max Finderif X > Max then Max = XFinding maximum
Flag/ExistenceA = 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

ExpressionTrue When…
A and BBOTH true
A or BAT LEAST ONE true
not AA 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

ColumnExpected TypeError Examples
Card NumberInteger”One”, “1.5”, text
Letter CountPositive Integer-5, 0, decimal
Part of SpeechNoun/Verb/etc.”Unknown”, number
Year4-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

  1. Draw a table with columns: Iteration, Card Data, Variable Values.
  2. Process one card at a time.
  3. 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

SymbolMeaning
OvalStart/End
RectangleProcess/Action
DiamondDecision (Yes/No)
ParallelogramInput/Output
ArrowFlow 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

  1. Reset Bug: Repeat from Step 2 when Step 2 initializes variables.
  2. Count vs Flag: A = A + 1 (count) vs A = 1 (existence).
  3. Argument Order: compare(A, B) vs compare(B, A) → Different results!
  4. AND vs OR: A and B is stricter than A or B.
  5. Nested IF: Same as AND, not OR.
  6. Pair Counting: (A,B) and (B,A) count as 2 pairs.
  7. Empty Pile Check: Must be at START of loop, not end.
  8. Data Types: “One” is NOT an integer.
  9. Letter Count Zero: Words MUST have ≥1 letter.
  10. 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. 🔥