Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

P, NP and NP-Complete: Understanding Polynomial Time and Non-Deterministic Problems, Study notes of Algorithms and Programming

The concepts of p, np, and np-complete problems in computer science. It discusses the differences between polynomial time problems and intractable problems, the argument that mazes are not in p, and the implications of this for maze solving algorithms. The document also introduces non-deterministic polynomial time problems and the concept of np-completeness.

Typology: Study notes

Pre 2010

Uploaded on 08/19/2009

koofers-user-rc6
koofers-user-rc6 🇺🇸

10 documents

1 / 39

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
P,NPandNPComplete
COMP157
Dec5,2007
xkcd.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27

Partial preview of the text

Download P, NP and NP-Complete: Understanding Polynomial Time and Non-Deterministic Problems and more Study notes Algorithms and Programming in PDF only on Docsity!

P,

NP

and

NP

Complete

COMP

Dec

xkcd.com

Growth

Functions

< day

< month

year

polynomial time

Intractable

problems

The

Halting

Problem

  • undecidable

permutation

generation

  • O(n!)

travelling

salesman?

knapsack?

www.shawnolson.net

How hard

are

mazes?

Mazes

P?

LongestPath(G,u,v,k): Is

there

a

simple

(non

cyclic)

path

in

G

from

vertex

u

to

vertex

v

of

length

k?

LongestPath

P

Poundstone

argues

that

a

maze

is

equivalent

to

LongestPath(Maze,

start,

goal,

therefore

Maze

P

What

is

wrong

with

his

argument?!?!?

Maze

Solving:

Search

A

maze

is

simply

an

undirected

graph.

Each

junction

is

a

vertex

and

corridors

are

edges.

BFS:

Let

b

be

the

average

branching

factor

(assume

b=2)

BFS

builds

a

tree

of

paths

tree

height,

h,

is

length

of

shortest

path

from

start

to

goal

tree

has

2

h

nodes,

complexity

is

O(

h

)?

Maze

Solving:

Shortest

Path?

Can

we

apply

Floyd’s

Algorithm,

O(n

3

for

all

pairs

shortest

path?

Dijkstra’s

algorithm,

O(|V|

2

for

single

source

shortest

paths?

We’d need to first build an adjacency matrixor adjacency list,which requires traversing the entire graph

BFS? DFS? …

Self

Replicating

Maze

Robot

How

long

will

it

take

for

some

copy

of

the

robot

to

reach

the

goal?

Infinite

Resources

Simultaneously

traversing

all

paths

is

equivalent

to

breadth

first

search

We

will

reach

goal

in

the

time

it

takes

to

traverse

the

shortest

path

to

the

goal

Time

to

solve

the

maze

is

O(|V|)

(in

the

unrealistic

world

of

infinite

resources)

Non

Determinism

The

self

replicating

robots

are

an

example

of

a

non

deterministic

computer

(NDC)

An

NDC

gets

to

a

solution

in

the

shortest

possible

time.

Alternative

views:

NDC

is

a

perfect

guesser:

only

has

to

verify

that

guess

is

correct

NDC

is

can

simultaneously

check

every

possible

solution