liveBook · Manning

Np-complete problem

As explained in Advanced Algorithms and Data Structures

A decision problem that belongs to NP and is at least as hard as every problem in NP under polynomial-time reductions.

An NP-complete problem is a decision problem whose proposed solutions can be verified quickly, yet whose optimal solution has no known polynomial-time algorithm. The 0-1 knapsack problem illustrates the practical consequence: exploring every subset can become impossibly slow as the number of items grows. section 1.3.3

When a problem is NP-complete, evaluate the constraints before abandoning the task:

  • Avoid exhaustive search when combinations grow explosively; 62 items already produce billions of billions of possible combinations. section 1.3.3
  • Exploit bounded numeric inputs when available: dynamic programming solves the knapsack instance in proportion to capacity times item count, rather than all subsets. section 1.3.3
  • Question restrictive assumptions: allowing repeated or fractional item quantities changes the problem and can enable a greedy algorithm. section 1.3.4

Cargo selection

A launch team must select goods for a 1,000-kilogram crate while maximizing calories. With 62 indivisible items, exhaustive subset search is impractical, but capacity-based dynamic programming requires roughly 1,000 × 62 steps. If fractional quantities are allowed, sorting by calories per kilogram and filling the remaining space greedily yields an easier variant. section 1.3.3 section 1.3.4

How Advanced Algorithms and Data Structures covers it

How deep it goes
Defines verification and search difficulty, then applies them to knapsack without proving reductions or complexity-class theory.
Examples
Uses launch-cargo packing with 62 items, 1,000-kilogram capacity, exhaustive subsets, dynamic programming, and fractional greedy packing.
What you can do after
Evaluate/understand when exhaustive search is infeasible and select dynamic programming or greedy reformulation for knapsack variants.
How it connects
Connects NP-complete problems with 0-1 knapsack, dynamic programming, pseudo-polynomial algorithms, unbounded knapsack, and greedy algorithms.

Also explained in

Compare how 2 books explain np-complete problem →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.