Practice Generalization in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

Generalization is the process of taking a pattern that appears in several examples and turning it into a rule or method that works in many cases. In computational thinking, it helps students move from one solved example to a reusable strategy.

Solve one case carefully, notice what stays the same, then write one rule that fits many cases.

Showing a random 20 of 80 problems.

Example 1

challenge
A hard-coded depth-first search uses a stack. A breadth-first search uses a queue. What single algorithm generalizes both?

Example 2

challenge
Conjecture: 'every odd number n≥3 is the sum of three primes.' Test for n=3,5,7,9,11 and state which case shows the conjecture must allow primes to repeat.

Example 3

medium
A specific check 'x≥18 AND x≤65' was used for ages 18-65. Generalize this membership test for bounds a and b.

Example 4

challenge
Given f(1)=1,f(2)=2,f(3)=4,f(4)=8,f(5)=16, a student writes f(n)=2n−1. The actual rule counts regions formed by n points on a circle joined by all chords, where f(6)=31. Why does 2n−1 fail, and what does this show?

Example 5

medium
From `T(1)=1, T(2)=3, T(3)=6, T(4)=10`, what closed-form rule for T(n) generalizes the pattern?

Example 6

medium
From f(0)=1,f(1)=2,f(2)=4,f(3)=8, what general rule fits, and how would you verify it in code?

Example 7

hard
A student sees that n=1,2,3,4 all give n2≥n and concludes 'square is always at least the number itself.' For which real numbers n does this fail?

Example 8

medium
From g(1)=2, g(2)=5, g(3)=10, g(4)=17, find a general rule.

Example 9

easy
To greet any user, the messages were 'Hi Ann', 'Hi Bob', 'Hi Cy'. Generalize the message for a name x.

Example 10

hard
Outputs for inputs 1, 2, 3, 4, 5 are 2, 6, 12, 20, 30. Find a general rule.

Example 11

easy
From h(1)=4, h(2)=7, h(3)=10, find a general rule for h(n).

Example 12

easy
Cubes: side 1 has volume 1, side 2 has volume 8, side 3 has volume 27. Generalize for side s.

Example 13

medium
From 22=4, 23=8, 24=16 a student writes 2n. What general rule covers the product 2a⋅2b?

Example 14

hard
A bubble sort, an insertion sort, and a selection sort all sort lists in O(n2). What's the danger of over-generalizing them into 'they're all the same'?

Example 15

hard
A web framework has hand-written handlers for `/user/1/posts`, `/user/2/posts`, etc. Generalize to a single route pattern and handler.

Example 16

easy
A function gives g(0)=1, g(1)=3, g(2)=5, g(3)=7. What general rule fits?

Example 17

hard
From a specific check 'string of length 5 has 5 indices, 0 to 4' generalize to any string of length n and state the valid index range.

Example 18

easy
A snack pack has 4 cookies. With 1 pack you have 4 cookies, with 2 packs 8, with 3 packs 12. Generalize for p packs.

Example 19

medium
A program multiplies a list by a constant: [1,2,3]→[3,6,9] used factor 3. Generalize the output for factor c and element x.

Example 20

medium
From f(2)=7,f(3)=10,f(4)=13, write a rule and predict f(10).