IB Computer Science Practice (Interactive)
Intuition
CS practice is like building with tools, each concept (variables, loops, functions) is a tool in your programming toolkit: Programming skills develop through practice, reading code, writing code, and debugging are all essential learning activities
Why it matters: Regular practice builds the problem-solving intuition needed for complex projects and exams
The key insight: Programming skills develop through practice, reading code, writing code, and debugging are all essential learning activities
IB — Computer Science Practice
10 auto-graded practice problems. Select an answer, submit, and review the explanation.
Worked Examples
Example 1: Boolean Logic
Problem: Simplify the Boolean expression:
Solution: Step 1: (complement law: a variable ANDed with its complement is always false)
Step 2: (identity law: 0 OR anything is that thing)
Step 3: Answer:
Key insight: Boolean algebra simplification follows the same rules as regular algebra, but with AND as multiplication and OR as addition. The key laws are: , , , .
Example 2: Big-O Analysis
Problem: Analyse the time complexity of this pseudocode:
for i = 1 to n:
for j = 1 to n:
print(i * j)
Solution: Step 1: Outer loop runs n times
Step 2: Inner loop runs n times for each iteration of outer loop
Step 3: Total operations =
Step 4: Time complexity:
Key insight: For nested loops, multiply the number of iterations. If the inner loop depends on the outer loop variable (e.g., for j = 1 to i), the complexity is .
Example 3: Binary Search Trace
Problem: Trace binary search for target 13 in array [2, 5, 8, 12, 16, 23, 38].
Solution: Step 1: low = 0, high = 6, mid = 3, array[3] = 12
Step 2: 12 < 13, so search right half: low = 4, high = 6
Step 3: mid = 5, array[5] = 23
Step 4: 23 > 13, so search left half: low = 4, high = 4
Step 5: mid = 4, array[4] = 16
Step 6: 16 > 13, so search left half: low = 4, high = 3
Step 7: low > high → target not found
Key insight: Binary search eliminates half the remaining elements at each step, which is why it’s . But the array must be sorted first.
System Fundamentals
Computer Organization
Networks and Algorithms
Data Structures, Databases, and OOP
Common Mistakes
Confusing syntax errors with logic errors: Syntax errors prevent code from running (missing semicolons). Logic errors produce wrong output (incorrect algorithm). Don’t confuse debugging approaches.
Forgetting that arrays start at index 0: In most programming languages, the first element is at index 0, not 1. Off-by-one errors are extremely common.
Mixing up pass-by-value with pass-by-reference: Pass-by-value copies the value. Pass-by-reference shares the original. Modifying a parameter in a function affects the original only with pass-by-reference.
Cross-References
- System Fundamentals: CS fundamentals are essential
- Algorithms: Algorithm design is core
- Networking: Networks are a major topic