Docsity

Lecture 14: Intractable Problems in Computer Science - Prof. David Evans, Study notes of Computer Science

Toggle sidebar
bg1
1
David Evans
http://www.cs.virginia.edu/evans
Class 14:
Intractable
Problems
CS150: Computer Science
University of Virginia
Computer Science
2
CS150 Fall 2005: Lecture 14: Intractable Problems
Smileys Problem
Input: nsquare tiles
Output: Arrangement of the
tiles in a square, where the
colors and shapes match up,
or ā€œno, its impossibleā€.
Thanks to Peggy Reed for
making the Smiley Puzzles!
4
CS150 Fall 2005: Lecture 14: Intractable Problems
Problems and Procedures
• To know a
O
(f)bound for a problem, we
need to find a Θ(f)
procedure
that solves it
– The sorting problem is
O
(n log n) since we
know a procedure that solves it in Θ(n log n)
• To know a Ω(f )bound for a problem,
we need to prove that there is no
procedure faster than Θ(f)that solves it
– We proved sorting is Ω(n log n) by reasoning
about the number of decisions needed
5
CS150 Fall 2005: Lecture 14: Intractable Problems
How much work is the
Smiley’s Problem?
• Upper bound: (
O
)
O
(n!)
Try all possible permutations
• Lower bound: (Ω)
Ω(n)
Must at least look at every tile
• Tight bound: (Īø)
No one knows!
6
CS150 Fall 2005: Lecture 14: Intractable Problems
Complexity Class P
ā€œTractableā€
Class P: problems that can be solved in
polynomial time
O
(nk)for some constant k.
Easy problems like sorting, making a
photomosaic using duplicate tiles,
simulating the universe are all in P.
pf3

Partial preview of the text

Download Lecture 14: Intractable Problems in Computer Science - Prof. David Evans and more Study notes Computer Science in PDF only on Docsity!

David Evans

http://www.cs.virginia.edu/evans

Class 14:

Intractable

Problems

CS150: Computer Science University of Virginia Computer Science CS150 Fall 2005: Lecture 14: Intractable Problems 2

Smileys Problem

Input: n square tiles

Output: Arrangement of the

tiles in a square, where the

colors and shapes match up,

or ā€œno, its impossibleā€.

Thanks to Peggy Reed for

making the Smiley Puzzles!

CS150 Fall 2005: Lecture 14: Intractable Problems 4

Problems and Procedures

• To know a O ( f ) bound for a problem, we

need to find a Θ( f ) procedure that solves it

– The sorting problem is O ( n log n ) since we

know a procedure that solves it in Θ( n log n )

• To know a Ī©( f ) bound for a problem,

we need to prove that there is no

procedure faster than Θ( f ) that solves it

– We proved sorting is Ī©( n log n ) by reasoning

about the number of decisions needed

CS150 Fall 2005: Lecture 14: Intractable Problems 5

How much work is the

Smiley’s Problem?

• Upper bound: ( O)

O ( n !)

Try all possible permutations

• Lower bound: (Ī©)

Ī© ( n )

Must at least look at every tile

• Tight bound: (Īø)

No one knows!

CS150 Fall 2005: Lecture 14: Intractable Problems 6

Complexity Class P

ā€œTractableā€

Class P: problems that can be solved in

polynomial time

O ( n

k

) for some constant k.

Easy problems like sorting, making a

photomosaic using duplicate tiles,

simulating the universe are all in P.

CS150 Fall 2005: Lecture 14: Intractable Problems 7

Complexity Class NP

Class NP: problems that can be solved in

nondeterministic polynomial time

If we could try all possible solutions at once, we

could identify the solution in polynomial time.

Alternately: If we had a magic guess-correctly

procedure that makes every decision correctly,

we could devise a procedure that solves the

problem in polynomial time.

Note: this definition is not precise enough to be satisfying yet! We will

need to understand better what a ā€œstepā€ means when we measure work

to define this properly.

CS150 Fall 2005: Lecture 14: Intractable Problems 8

NP Problems

  • Can be solved by just trying all possible

answers until we find one that is right

  • Easy to quickly check if an answer is right
    • Checking an answer is in P
  • The smileys problem is in NP

We can easily try n! different answers

We can quickly check if a guess is

correct (check all n tiles)

CS150 Fall 2005: Lecture 14: Intractable Problems 9

Is the Smiley’s Problem in P?

No one knows!

We can’t find a O ( n

k ) solution.

We can’t prove one doesn’t exist.

CS150 Fall 2005: Lecture 14: Intractable Problems 10

Orders of Growth

1 2 3 4 5 6 7 8 9 10

logn n

nlogn n^

n^3 2^n

insertsort

simulating

universe

quicksort

smileys puzzle

2

n < n!

CS150 Fall 2005: Lecture 14: Intractable Problems 11

Orders of Growth

logn n

nlogn n^

n^3 2^n

insertsort

simulating universe

quicksort

smileys

puzzle

CS150 Fall 2005: 12

Orders of Growth

0

200000

400000

600000

800000

1000000

1200000

logn n

nlogn n^

n^3 2^n

simulating universe

Smileys

puzzle

ā€œtractableā€

ā€œintractableā€

I do nothing that a man of unlimited funds, superb physical

endurance, and maximum scientific knowledge could not do.

  • Batman (may be able to solve intractable problems, but

computer scientists can only solve tractable ones for large n )