NPC vs NPH

 

NPC vs NPH 

NP-Complete (NPC)NP-Hard (NPH)
Must be in NP?YesNo, not necessarily
Must be at least as hard as every NP problem?YesYes
Solution can be verified in polynomial time?YesNot necessarily
Usually applies toDecision problemsDecision or optimization problems
ExampleHamiltonian CycleTSP optimization

The key idea

NP-Hard:

"This problem is at least as hard as every problem in NP."

NP-Complete:

"This problem is at least as hard as every problem in NP AND its solution can be verified in polynomial time."

Therefore:

NP-Complete=NP-Hard+belongs to NP\boxed{\text{NP-Complete} = \text{NP-Hard} + \text{belongs to NP}}

Think of it as two conditions

For a problem to be NP-Complete, ask two questions:

1. Is it in NP?

Can we verify a proposed solution in polynomial time?

Yes → continue.

2. Is it NP-Hard?

Is it at least as hard as every problem in NP?

Yes → NP-Complete.

So:

                 NP-HARD
              ┌───────────────┐
              │               │
              │   NP          │
              │ ┌───────────┐ │
              │ │    NPC    │ │
              │ └───────────┘ │
              │               │
              └───────────────┘

The NP-Complete problems are the part of NP that is also NP-Hard.


Example: TSP

TSP Optimization

Find the minimum-cost tour visiting every city exactly once.

This is an optimization problem and is NP-Hard.

Why not call it NP-Complete?

Because NP-Complete is defined for decision problems, and this version asks us to find the best tour.

TSP Decision

Is there a tour with total cost ≤ K?

This has a YES/NO answer.

A proposed tour can be verified in polynomial time, and the problem is NP-Hard.

Therefore:

TSP Decision is NP-Complete\boxed{\text{TSP Decision} \text{ is NP-Complete}}

One-line memory trick

🟢 NPC = NP-Hard + Verifiable in polynomial time

or even shorter:

NPH = Hardness
\boxed{\text{NPH = Hardness}}
NPC = Hardness + Verification\boxed{\text{NPC = Hardness + Verification}}

Important: Every NP-Complete problem is NP-Hard, but not every NP-Hard problem is NP-Complete.

Comments

Popular posts from this blog

Design and Analysis of Algorithms PCCST502 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Greedy Algorithm-Fractional Knapsack Problem

Introduction to Algorithms