Algorithm Efficiency Examples in CS Thinking
Start with the recap, study the fully worked examples, then use the practice problems to check your understanding of Algorithm Efficiency.
This page combines explanation, solved examples, and follow-up practice so you can move from recognition to confident problem-solving in CS Thinking.
Concept Recap
Big-O notation describes the asymptotic growth of an algorithm's cost as input size increases — most often applied to worst-case running time or memory, expressed as , , , etc.
Does doubling the data double the time? Or quadruple it? Or barely change it?
Read the full concept explanation →How to Use These Examples
- Read the first worked example with the solution open so the structure is clear.
- Try the practice problems before revealing each solution.
- Use the related concepts and background knowledge badges if you feel stuck.
What to Focus On
Core idea: Algorithm efficiency matters increasingly as data grows—a slow algorithm on small data may fail completely on large data.
Common stuck point: Big O ignores constant factors— and are both because the growth rate is what matters.
Sense of Study hint: When analyzing efficiency, first identify the input size . Then count how many times the most-repeated operation executes as a function of (look for nested loops). Finally, express the growth rate using Big O, dropping constants and lower-order terms.
Worked Examples
Example 1
hardAnswer
First step
See the full worked solution + why-it-works coaching
SetupKey insightWhy it worksCommon pitfallConnection
Example 2
hardExample 3
mediumExample 4
mediumExample 5
mediumExample 6
hardExample 7
hardExample 8
hardExample 9
hardExample 10
challengeExample 11
hardExample 12
mediumExample 13
mediumExample 14
mediumExample 15
mediumExample 16
hardExample 17
hardExample 18
hardExample 19
hardExample 20
challengePractice Problems
Try these problems on your own first, then open the solution to compare your method.
Example 1
hardExample 2
hardExample 3
easyExample 4
easyExample 5
easyExample 6
easyExample 7
easyExample 8
easyExample 9
easyExample 10
easyExample 11
mediumExample 12
mediumExample 13
mediumExample 14
mediumExample 15
mediumExample 16
mediumExample 17
mediumExample 18
challengeExample 19
challengeExample 20
challengeExample 21
mediumExample 22
mediumExample 23
easyExample 24
easyExample 25
easyExample 26
mediumExample 27
mediumExample 28
mediumExample 29
mediumExample 30
hardExample 31
hardExample 32
hardExample 33
mediumExample 34
mediumExample 35
challengeExample 36
easyExample 37
easyExample 38
easyExample 39
easyExample 40
mediumExample 41
mediumExample 42
mediumExample 43
mediumExample 44
mediumExample 45
hardExample 46
hardExample 47
hardRelated Concepts
Background Knowledge
These ideas may be useful before you work through the harder examples.