Computational complexity and P vs NP · Professor Patchouli Knowledge
Chapters 1–3 are available. The written lesson, laboratory and exercises are available now. No calculus or programming is required. Allow 60–90 minutes for reading and practice, plus video time.
Professor Patchouli will begin with the limits of brute force. Why can't we simply buy a faster computer? What makes some problems so difficult? Is finding an answer fundamentally harder than checking one?
By the end you should be able to count candidate solutions, distinguish growth rates, estimate time and energy, explain binary search and distinguish finding from checking a solution.
A variable is a symbol for a quantity: n might be the number of boxes or switches. A power such as 2⁵ means multiplying five factors of 2, giving 32. In contrast, 5² = 25. Adding one to the exponent doubles a power of two. The logarithm log₂(x) asks which exponent produces x: log₂(32)=5. For a positive x between powers of two, the logarithm lies between their exponents.
Scientific notation expresses large or small numbers as a coefficient times a power of ten: 1 billion = 10⁹; 1 trillion = 10¹²; 1 picojoule (pJ) = 10⁻¹² joules. One hour is 3600 seconds; one day is 86400 seconds. A watt is one joule per second, and one terawatt-hour (TWh) is 3.6 × 10¹⁵ joules.
An algorithm is a finite procedure for solving a specified problem. Brute force checks candidates until it finds a solution or exhausts them. In the worst case, searching n unsorted boxes takes n checks. We count operations under an explicit model rather than treating every operation as equally expensive on every real computer.
To count unordered pairs among n objects, choose the first object in n ways and the second in n−1 ways. Each pair is counted twice, so divide by two. For n independent two-state switches, multiply two choices for each switch: 2ⁿ configurations.
Linear work grows in proportion to n; quadratic work grows roughly as n²; exponential work such as 2ⁿ doubles whenever n increases by one. Logarithmic work grows slowly: doubling n adds about one to log₂(n). Faster hardware reduces elapsed time for fixed work, not the mathematical growth of that work. If a machine checks r candidates per second and each costs e joules, W checks take W/r seconds and consume W × e joules in this simplified model.
1. 16, 256, 6. 2. 6×5/2=15. 3. 4096. 4. 2 hours and 1 mJ. 5. 25 seconds. If these are difficult, revisit Reading A before continuing.
Watch individual chapters below, or use continuous playback after the chapter handouts. Chapters 4–8 are in production.
Japanese audio · English subtitles · 60 fps
Japanese audio · English subtitles · 60 fps
Review the four lecture slides. Select any image to open the full-resolution PNG in a new tab.
Japanese audio · English subtitles · 60 fps
Review the six lecture slides. Try the question before opening the answer.






All currently available chapters play consecutively in this player. Use the buttons to move between chapters.
Open full-screen lecture player
Change the problem size, speed and energy cost. All calculations are hypothetical, not hardware benchmarks. No actual exhaustive search is performed.
| Growth model | Checks | Time | Energy (J) |
|---|
1. About 1.07 s, 18.3 min, 13.0 days and 36.5 years. 2. About 13.3 days versus 13.0 days: a 1000-fold speedup almost offsets ten additional switches (1024-fold work). 3. About 1.27×10¹⁸ J and 1.30×10²¹ J, a factor of 1024. 4. Different growth laws produce dramatically different work counts; hardware speed scales time but leaves counts unchanged.
The written tutorial is ready even while the video is pending. Attempt each problem before revealing the worked solution.
Find worst-case checks for 1000 unsorted boxes and the number of unordered pairs among 1000 objects.
1000 boxes require at most 1000 checks; pairs = 1000×999/2 = 499500. Doubling the number of objects roughly quadruples pair work.
How many additional switches can a 1,000,000-fold faster computer exhaustively search in the same time?
log₂(10⁶) ≈ 19.93. Exactly 19 extra whole switches fit within the same budget; 20 is the approximate gain and needs 1,048,576-fold speed.
At 1 pJ per configuration, find the energy for 100 switches in joules and TWh.
2¹⁰⁰ × 10⁻¹² ≈ 1.268×10¹⁸ J. Divide by 3.6×10¹⁵ to get about 352 TWh. This is an illustrative model, not a universal energy limit.
Find card 731 in sorted cards 1–1024 using the lower middle of the remaining interval each time.
512, 768, 640, 704, 736, 720, 728, 732, 730, 731. Each comparison eliminates roughly half the remaining candidates. Worst case for this implementation is 11 comparisons. Efficient access to the middle and sorted order are essential.
Why can checking a completed Sudoku be easier than finding it? Does that prove P ≠ NP?
Check the givens and row, column and block rules without replaying the search. This illustrates verification, not a proof of a complexity separation. Complexity theory considers generalised puzzles with growing input size, not just a fixed 9×9 board.
| Concept | Rule / reminder |
|---|---|
| Linear search | n worst-case checks |
| Unordered pairs | n(n−1)/2 |
| Binary configurations | 2ⁿ |
| Binary search | ⌊log₂(n)⌋+1 worst-case comparisons for n≥1, sorted random-access data |
| Time and energy | W/r seconds; W×e joules |
| Hardware gain s | log₂(s) extra switches approximately; round down for whole switches |
| P | Decision problems solvable in deterministic polynomial time |
| NP | Decision problems whose yes instances have polynomial-size certificates verifiable in polynomial time |
P is contained in NP. Whether P=NP remains unresolved. NP does not mean “not polynomial”. Polynomial time is a mathematical growth criterion, not a guarantee of practical speed. Reversible computing can address physical costs but does not automatically change exponential work into polynomial work.
Why does a 1000-fold speedup buy only about ten extra switches? Why is binary search not appropriate for arbitrary unsorted data? What assumptions are hidden in the energy model? Why is checking a proposed solution not the same as finding one?
2¹⁰=1024; binary search needs ordering and efficient middle access; the model assumes fixed cost per check and omits overhead; verification uses a supplied candidate rather than searching for it.
Target: 8/10 (80%). Retry freely. Also complete the laboratory and explain your reasoning in the written tutorial; the quiz alone is not a full assessment.
Session 02 — What is computation? (planned). If you are not ready, revisit the readings above. There is no deadline.