• 沒有找到結果。

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao

N/A
N/A
Protected

Academic year: 2022

Share "Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao"

Copied!
43
0
0

加載中.... (立即查看全文)

全文

(1)
(2)

▪ Decision Problems v.s. Optimization Problems

▪ Complexity Classes

▪ P v.s. NP

▪ NP, NP-Complete, NP-Hard

2

(3)

Design Strategy

Divide-and-Conquer

Dynamic Programming

Greedy Algorithms

Graph Algorithms

Analysis

Amortized Analysis

NP-Completeness

(4)

4

For an input with size n, the worst-case running time is for some constant k

Problems that are solvable by polynomial-time algorithms as being tractable, easy , or efficient

Problems that require superpolynomial time as being

intractable, or hard, or inefficient

(5)

Use total four colors s.t. the neighboring parts have different colors

(6)

Finally proven (with the help of computers) by Kenneth Appel and Wolfgang Haken in 1976

Their algorithm runs in O(n2) time

First major theorem proved by a computer

Open problems remain...

Linear time algorithms to find a solution

Concise, human-checkable, mathematical proofs

6

(7)

Given a planar graph G (e.g., a map), can we color the vertices with k colors such that no adjacent vertices have the same color?

k = 1?

k = 2?

k = 3?

k ≥ 4?

How hard is it when k = 3?

(8)

8

(9)

9

(10)

Definition: the answer is simply “yes” or “no” (or “1” or “0”)

MST: Given a graph 𝐺 = 𝑉, 𝐸 and a bound 𝐾, is there a spanning tree with a cost at most 𝐾?

KNAPSACK: Given a knapsack of capacity 𝐶, a set of objects with weights and values, and a target value 𝑉, is there a way to fill the knapsack with at least 𝑉 value?

10

(11)

Definition: each feasible solution has an associated value, and we wish to find a feasible solution with the best value (maximum or minimum)

MST-OPT: Given a graph 𝐺 = 𝑉, 𝐸 , find the minimum spanning tree of 𝐺

KNAPSACK-OPT: Given a knapsack of capacity 𝐶 and a set of objects with weights and values, fill the knapsack so as to maximize the total value

(12)

12

How to convert an optimization problem to a related decision problem?

Imposing a (lower or upper) bound on the value to be optimized

(13)

Every optimization problem has a decision version that is no harder than the optimization problem.

Using Aopt to solve Adec

check if the optimal value ≤ k, constant overhead

Using Adec to solve Aopt

apply binary search on the value range, logarithmic overhead

Aopt: given a graph, find the length of the shortest path

Adec: given a graph, determine whether there is a path ≤ k

(14)

Textbook Chapter 34 – NP-Completeness

14

(15)

Algorithmic design methods to solve problems efficiently (polynomial time)

Divide and conquer

Dynamic programming

Greedy

“Hard” problems without known efficient algorithms

Hamilton, knapsack, etc.

(16)

Can we decide whether a problem is “too hard to solve” before investing our time in solving it?

Idea: decide which complexity classes the problem belongs to via reduction

已知問題A很難。若能證明問題B至少跟A一樣難,那麼問題B也很難。

16

(17)

Algorithm design

Design algorithms to solve computational problems

Mostly concerned with upper bounds on resources

Complexity theory

Classify problems based on their difficulty and identify relationships between classes

Mostly concerned with lower bounds on resources

upper bound

Problem Problem B

Problem A

lower bound

(18)

A complexity class is “a set of problems of related resource- based complexity”

Resource = time, memory, communication, ...

Focus: decision problems and the resource of time

18

(19)

The class P consists of all the problems that can be solved in polynomial time.

Sorting

Exact string matching

Primes

Polynomial time algorithm

For inputs of size n, their worst-case running time is for some constant k

(20)

20

NP consists of the problems that can be solved in non- deterministically polynomial time.

NP consists of the problems that can be “verified” in polynomial time.

P consists of the problems that can be solved in (deterministically) polynomial time.

Non-Deterministic

(21)

initial

configuration

(22)

22

initial

configuration

(23)

This is not a randomized algorithm.

Non-Deterministic-Bubble-Sort(n) for i = 1 to n

for j = 1 to n – 1

if A[j] < A[i+1] then

Either exchange A[j] and A[i+1] or do nothing

(24)

Input: a graph G

Output: a smallest vertex subset of G that covers all edges of G.

Known to be NP-complete

24

(25)
(26)

26

Input: a Graph G and an integer k.

Output: Does G contain a vertex cover of size no more than k?

Original problem → optimization problem

原先的路燈問題是要算出放路燈的方法

Yes/No → decision problem

問k盞路燈夠不夠照亮整個公園

(27)

Non-Deterministic-Vertex-Cover(G, k) set S = {}

for each vertex x of G

non-deterministically insert x to S if |S| > k

output no

if S is not a vertex cover output no

output yes

(28)

28

If the correct answer is yes, then there is a computation path of the algorithm that leads to yes.

至少有一條路是對的

If the correct answer is no, then all computation paths of the algorithm lead to no.

每一條路都是對的

Non-Deterministic-Vertex-Cover(G, k) set S = {}

for each vertex x of G

non-deterministically insert x to S if |S| > k

output no

if S is not a vertex cover output no

output yes

(29)

initial

configuration

(30)

30

polynomial

“solved” in non-deterministic polynomial time

= “verified” in polynomial time

(31)

P ⊆ NP

A problem solvable in polynomial time is verifiable in polynomial time as well

Any NP problem can be solved in (deterministically) exponential time?

Yes

Any NP problem can be solved in (deterministically) polynomial time?

Open problem

Why?

(32)

http://www.claymath.org/millennium-problems

32

(33)

Yang–Mills and Mass Gap

Riemann Hypothesis

P vs NP Problem

Navier–Stokes Equation

Hodge Conjecture

Poincaré Conjecture (solved by Grigori Perelman)

Birch and Swinnerton-Dyer Conjecture

Grigori Perelman

(34)

Aug 2010 claimed a proof of P is not equal to NP.

34

(35)

problems that are verifiable → solvable

public-key cryptography will be broken

Widespread belief in P ≠ NP

“If P = NP, then the world would be a profoundly different place than we usually assume it to be. There would be no special value in “creative leaps,” no fundamental gap between solving a problem and recognizing the solution once it's found. Everyone who could appreciate a symphony would be Mozart; everyone who could follow a step-by-step argument would be Gauss...” – Scott Aaronson, MIT

(36)

36

Travelling Salesman (2012)

A movie about P = NP

Best Feature Film in Silicon Valley Film Festival 2012

(37)

37

(38)

38

A problem is NP-hard if it is as least as hard as all NP problems.

In other words, a problem X is NP-hard if the following condition holds:

If X can be solved in (deterministic) polynomial time, then all NP problems can be solved in (deterministic) polynomial time.

(39)

A problem is NP-complete if

it is NP-hard and

it is in NP.

In other words, an NP-complete problem is one of the “hardest”

problems in the class NP.

In other words, an NP-complete problem is a hardness representative problem of the class NP.

Hardest in NP → solving one NPC can solve all NP problems (“complete”)

It is wildly believed that NPC problems have no polynomial-time solution

→ good reference point to judge whether a problem is in P

We can decide whether a problem is “too hard to solve” by showing it is as hard as an NPC problem

(40)

Class P: class of problems that can be solved in

Class NP: class of problems that can be verified in

Class NP-hard: class of problems that are “at least as hard as all NP problems”

Class NP-complete: class of problems in both NP and NP-hard

P ≠ NP P = NP 40

(41)

undecidable: no algorithm;

e.g. halting problem

https://www.youtube.com/watch?v=wGLQiHXHWNk

(42)

42

(43)

Course Website: http://ada.miulab.tw Email: ada-ta@csie.ntu.edu.tw

43

Important announcement will be sent to @ntu.edu.tw mailbox

& post to the course website

參考文獻

相關文件

▪ Step 2: Run DFS on the transpose

Greedy-Choice Property : making locally optimal (greedy) choices leads to a globally optimal

 From a source vertex, systematically follow the edges of a graph to visit all reachable vertices of the graph.  Useful to discover the structure of

 “Greedy”: always makes the choice that looks best at the moment in the hope that this choice will lead to a globally optimal solution.  When to

Write the following problem on the board: “What is the area of the largest rectangle that can be inscribed in a circle of radius 4?” Have one half of the class try to solve this

Since we use the Fourier transform in time to reduce our inverse source problem to identification of the initial data in the time-dependent Maxwell equations by data on the

✓ Express the solution of the original problem in terms of optimal solutions for subproblems. Construct an optimal solution from

✓ Express the solution of the original problem in terms of optimal solutions for subproblems.. Construct an optimal solution from