CSCI381 Fall 2004 - PowerPoint PPT Presentation

About This Presentation
Title:

CSCI381 Fall 2004

Description:

CS Theory Review. P/NP. Complexity of some example algorithms. 9/6/09 ... CS381/Fall04/GWU/Vora/CS Theory Review. 3. Definitions ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 15
Provided by: poo69
Category:
Tags: csci381 | fall | theory

less

Transcript and Presenter's Notes

Title: CSCI381 Fall 2004


1
CS Theory Review
  • P/NP
  • Complexity of some example algorithms
  • CSCI381 Fall 2004
  • GWU

2
Example Traveling Salesman
Given a set of points and the cost of going from
each to another, find a least cost path that
covers all points
n points Try all combinations T(n) n!
3
Definitions
  • Polynomial time When the worst-case running time
    of an algorithm is polynomial in the size of the
    input
  • Exponential time When the worst-case running
    time of an algorithm is exponential in the size
    of the input

4
Polynomial vs. Exponential
5
Non-deterministic Polynomial NP
  • When you can check that a solution is correct in
    polynomial time
  • Example Travelling Salesman, all polynomial-time
    algorithms, discrete log, roots of a polynomial

6
Computational Complexity
  • An NP-complete problem is one which, if solved in
    polynomial time, can be used to solve all other
    NP problems in polynomial time.
  • Example?

7
Computational Complexity
  • any NP-complete problem is solved in
    polynomial-time,
  • ? P NP
  • i.e. (problems solvable in polynomial time)
    (problems for which solutions can be checked in
    polynomial time)

8
Aside Computational Complexity
  • There are NP problems not known to have
    polynomial-time solutions which are also not
    known to be NP-complete i.e. they are difficult,
    but perhaps not among the most difficult

9
Computational Complexity
  • Computational complexity of the following
    operations on x (k bit) and y (l bit), k ? l
  • x y
  • x y
  • xy
  • Floor(x/y) O(l(k-l))

10
Euclidean Algorithm
  • gcd(m, n) / m gt n /
  • (a, b) (m, n) / Initialize /
  • while (b?0) (a, b) (b, a bq) /Where q
    ?a/b? /
  • return(a)
  • Complexity?

11
Computational Complexity mod n
  • Computational complexity of the following
    operations mod n, where n is a k-bit integer
  • x y
  • x y
  • xy

12
Efficient exponentiation(from Memon notes)
  • Usual approach to computing xc mod n is
    inefficient when c is large.
  • Example 551 involves 51 multiplications mod n
  • Instead, represent c as bit string bk-1 b0 and
    use the following algorithm
  • z 1
  • For i k-1 downto 0 do
  • z z2 mod n
  • if bi 1 then z z x mod n

13
Example
  • Calculate 751 mod 11 efficiently
  • 51 110011 25 24 21 20
  • 751 ((((72)2)2)2)2 ? (((72)2)2)2 ? 72 ? 71
  • How many multiplications did you need?

14
751 mod 11
i bi z
5 1
4 1
3 0
2 0
1 1
0 1
Write a Comment
User Comments (0)
About PowerShow.com