Limits to Computation - PowerPoint PPT Presentation

About This Presentation
Title:

Limits to Computation

Description:

Limits to Computation How do you analyze a new algorithm? Put it in the form of existing algorithms that you know the analysis. For example, given 2 arrays, pair the ... – PowerPoint PPT presentation

Number of Views:52
Avg rating:3.0/5.0
Slides: 12
Provided by: WilliamT155
Category:

less

Transcript and Presenter's Notes

Title: Limits to Computation


1
Limits to Computation
  • How do you analyze a new algorithm?
  • Put it in the form of existing algorithms that
    you know the analysis.
  • For example, given 2 arrays, pair the smallest in
    each array, the next smallest, etc.
  • Can be done by sorting each array and pairing
    first, second, etc.
  • No worse than O(n log n).

2
Algorithm Reduction
  • But is is possible to do pairings faster than O(n
    log n)?
  • Look at using pairings for sorting (without using
    sorting)
  • The second item of the paired results from
    pairing will tell us the position of the first
    item when it is sorted.
  • If we had a pairing algorithm that was faster
    than n log n, then we could take an arbitrary
    array, use an array of the integers 1,.., n
  • So if there is a pairing algorithm of O(n) we can
    do sorting in O(n). There is a proof that this
    cannot be done. So pairing must take at least
    O(n log n).

3
Hard Problems
  • A hard problem is a problem whose best know
    algorithm to solve it takes exponential time.
  • A Hard Algorithm is a problem that runs in
    exponential time.
  • It takes ?(cn) for some cgt1, where n is the
    problem size.

4
NP Problems
  • Assume you have a computer that finds solutions
    by guessing the answer and checks to see if
    that answer is correct.
  • Could be a super parallel computer that can test
    all possible solutions simultaneously.
  • If the answer cannot be checked in polynomial
    time (such as the towers of Hanoi), it is not an
    NP problem.

5
NP - Completeness
  • The algorithm using guessing is a
    nondeterministic algorithm.
  • Hence NP Nondeterministic polynomial.
  • Some NP problems do not have known efficient
    deterministic solutions.
  • Every problem in this set reduces to every other
    problem in this set.
  • If can solve one in polynomial time, can solve
    them all in polynomial time.

6
NP- Complete Problems
  • Traveling Salesman
  • K-Clique given an arbitrary undirected graph,
    is there a complete subgraph of at least k
    vertices.

7
Why know about NP-complete
  • If the best algorithm you can find for your
    problem is exponential then you may try to find a
    reduction into a problem that is NP-complete.
  • If you can, then you have shown that whereas your
    solution has not been shown to be the best, it is
    very difficult (and maybe impossible) to find a
    polynomial algorithm.

8
Heuristic
  • What to do when you must find a solution to an
    NP-complete problem?
  • Solve small problems
  • Solve special cases
  • Find an approximate solution one that is good,
    but not necessarily the best. (I.e., find a short
    path for the traveling salesman, not necessarily
    the shortest).
  • Go the to next closest city.

9
Impossible Problems
  • The halting problem given an arbitrary program
    P and the data D, determine (in finite time) if
    the program P will halt on data D.
  • Can prove that such a program cannot be written

10
Halting Problem Proof
  • Assume you have a halting program
  • bool halt(P,D)
  • Write a new program
  • bool selfhalt(P), calls halt(P, P)
  • This program will tell if the program P will halt
    when the input is the program P
  • P is restricted to programs that take programs as
    data

11
Final Step
  • Now write a function
  • bool contrary(P)if selfhalt(P) while(TRUE)
  • What happens when we do
  • contrary(contrary)?
  • Either contrary
  • 1. Halts, but then it does not halt
  • 2. Does not halt, but then it halts.
  • Contradiction so cannot write halt.
Write a Comment
User Comments (0)
About PowerShow.com