Skip to content
Tactiverge

Learning Rooms/✦ Level 5 · Research Engineer/Computing and algorithms

P vs. NP and the Computational Complexity Zoo

hackerdashery · Length: see YouTube · captions on YouTube · nothing loads until you press play

By the end you can…

  • Explain the difference between polynomial-time (tractable) and exponential-time problems.
  • Describe P, NP and NP-hard informally, using the idea that checking can be easier than finding.
  • Justify using a heuristic or approximation algorithm and measure its gap from the optimum on small cases.
?Predict▶Watch✓Practise⚙Build

Watch it all: no segment has been checked by hand for this video yet.

1.Predict before you press play

Going from 9 cities to 10 multiplies the number of distinct round trips by about…

Pick one before you press play. A wrong guess is fine: it is what makes the video stick.

2.See the idea first

Play with this diagram for a minute. It gives you something to hang the video on.

Loading the interactive…

Can't use the diagram? Read a description instead

The explorer draws 4 to 9 random cities with two routes: the exact best tour (found by trying all (n−1)!/2 tours) and the greedy nearest-neighbour tour. A table reports tours tried, both lengths and the percentage gap; at 20 cities brute force would need about 6×10¹⁶ tours.

3.Watch, actively

A brisk tour of what P and NP mean, why checking an answer can be easy when finding it seems hard, and why it matters to real engineering.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

Watch for…

  • → Listen for the difference between finding a solution and checking one: that gap is the whole P versus NP question.

Pause whenever you like. Rewatching a hard minute is a good habit, not a failure.

Can't stream it? Read the idea instead

Problems in P can be solved in time that grows like a polynomial in their size. For problems in NP a proposed answer can be checked quickly, though nobody knows a fast way to find one. Many scheduling and routing problems are like that, so engineers use good approximations.

What the video covers (our own note, written when we verified it): A brisk tour of what P and NP mean, why checking an answer can be easy when finding it seems hard, and why it matters to real engineering.

Written by Tactiverge in our own words, not a transcript. The full lesson below explains the idea without the video.

Read it instead

Jot down one thing that surprised you and one question you still have.

Private: saved only on this device, never sent to Tactiverge.

4.Practise what you just saw

These come from the lesson that use this video and are checked on the server. Wrong answers get a hint and another try.

Practice 1

How many distinct round trips (direction ignored) through 8 cities?

Practice 2

Your greedy scheduler beats random scheduling on every test. What should the report claim?

Practice 3 · a fresh version every time

How many times is work() called when n = 270? Code: for i in 0 … n−1: for j in i+1 … n−1: work()

calls

Practice 4

Which problem has a known polynomial-time algorithm?

5.Try it yourself

No simulation models this idea yet. The lesson below has an interactive diagram instead.

6.Where engineers use it

Chip design tools place millions of standard cells and route their wires: NP-hard problems at enormous scale. They use heuristics such as simulated annealing and analytic placement, and accept good rather than optimal layouts.

From the applied view in the lesson When exact answers are out of reach. Checked by automated tests only.

7.Build something with it

Follow-up project

In the explorer, record the greedy-to-optimal ratio on 20 random maps of 8 cities. Report the mean, the worst case and a histogram. Then propose one improvement to nearest neighbour (for example, 2-opt: reverse a segment if it shortens the tour) and predict whether it narrows the gap.

Where this video lives

In the course catalogue: CSE-510 Numerical solvers and complexity

The video is by hackerdashery, embedded from YouTube with privacy-enhanced mode and never autoplayed. The room around it (prompts, notes, practice, projects) is Tactiverge's, written with AI assistance and checked by automated tests only.