Aside:
Codeword error on hw: twiddling one letter can result in a loss of information:
"table" and "fable" both map from "5able".
In the space Σn,
the
Hamming distance between two words a,b:
let dist(a,b) be the numer of indices in which a,b differ.
Is dist(•,•) a metric?
Definition of metric:
Application to coding:
codewords are a subset of Σn
such that all points are at least distance (say) 3.
This means that if there are one or two errors,
you can detect that an error occured.
If only one error, you can recover the original.
(If two errors, you may inadvertently recover the wrong original.)
Define: the sphere of radius n around w, Bn(w): … . What is our codeword condition, in terms of these spheres? Note that the space is a discrete graph.
Fact: log(n!) = Θ(n log n). [Show.]
A lower bound on sorting: (Rosen 9.2) computation tree based on comparisons; has n! leaves; thus must have height lg(n!) = Ω(n log n) (Recall tree's size-vs-height bound from structural-induction lecture.)
We have a very complete picture for sorting: we know an lower bound for any algorithm, and and an algorithm which attains it. Usually we're not so lucky. For instance, as mentioned, we'd like to know that there's no quick way to factor numbers (that it's complexity is Θ(n), not just O(n).)
One counting argument: Recall that reals in [0,1] are uncountable. (Consider writing such numbers in binary.) How many functions are there, in N → {F,T}? This is isomorphic. How many programs exist? Countable. Therefore: There are functions which cannot be computed (!) Recall from comp210: The Halting Problem.
Note how we're distinguishing between a Problem, and various algorithms to solve (instances of) the problem.
Def'ns:
Note that P is contained in NP is contained in EXPTIME. Are these containments proper? Unknown (!) (Despite Homer3's assertion.)
Classify these problems as best possible:
Note that this last problem is artificial. It has the property that it's "NP-complete": if you can solve that problem quickly (in P time), then you could solve any problem in NP quickly.
For reductions, we require that a reduction be computable in P, so that we get the desired "can solve in polynomial time" relationship.
Th'm (Cook, 1974): SAT is NP-complete.
Proof sketch: Reduce has-PTIME-soln? to SAT:
Given a verifier and an input problem:
[Realize, this is very much a sketch.
Many problems of practical interest have been shown NP-complete. (The 10-coloring problem is assigning students to colleges, w/o having people from same high school in same college.) For instance, SAT can be reduced to 3-coloring: via a clever way of taking a formula, creating an equivalent formula with exactly 3 variables per clause (adding extra dummy variables), then taking these 3-clauses and constructing a weird graph that can be 3-colored iff the original formula was satisfied. We know that solving any of these is as difficult as solving all of them, and probably not worth your effort to try. Though there is a $1,000,000 cash prize for resolving P vs NP either way. (Some NP-complete problems allow approximate sol'ns, which might be good enough; for others NP-complete, finding an approximate sol'n is as difficult as finding the entire sol'n!)
Note that Minesweeper is NP-complete.
Reached here, 2004.Apr.20Now, a different tack: Flipping coins to gain computational power(?!)
Towards randomized algs and their running time:
Running time of quicksort?:
Hmm, look at avg-case time.
Hmm, need to define "average".
[Can set up recurrence, and show that any sol'n is bounded by O(n log n)]
For random partition, what is the size of the larger half?:
(We'll assume we keep the pivot itself out of either half (at least, one
occurrence of the pivot).)
1/n⋅max(0,n-1) + 1/n⋅max(1,n-2) + 1/n⋅max(2,n-3) + 1/n⋅max(3,n-4) + … + 1/n⋅(max(⌊n/2⌋,⌈n/2⌉) + 1/n⋅(max(⌈n/2⌉,⌊n/2⌋) + … + 1/n⋅max(n-4,3) + 1/n⋅max(n-3,2) + 1/n⋅max(n-2,1) + 1/n⋅max(n-1,0) = 1/n ⋅ [ (n-1) + (n-2) + … + ⌈n/2⌉ + ⌈n/2⌉ + … + (n-2) + (n-1) ] = 2/n ⋅ [ (n-1) + (n-2) + … + ⌈n/2⌉ ] = 2/n ⋅[ (n-1 + n/2) ⋅ (n-1)/4 ] = (3n-2)(n-1)/4n = (3n^2-5n+2)/4n = 3n/4 + O(1)(We're being a bit sloppy here about whether n is even or odd; with a bit of care, this can be patched over w/o problem.)
Note how randomization helped our quicksort alg. Consider too:
BUT, Miller came up with a very clever alternate test:
For a number n and b < n, The Miller test of n with base b:
Let n-1 = 2st, where s non-negative and t odd.
It passes iff:
How to amplify this algorithm?
Likelihood of a cosmic ray hitting a transistor with enough energy to flip a bit while our program is running: < 1060 [guess]
Don't be confused by raging threads on sci.math: "a number is prime or it isn't; nonsensical to say it's prime with probability …". Whenever you give a probability, you have to say what you're randomizing over!
Even more intriguingly:
Recently,
primality
has been shown to be in PTIME
(no randomness required).
Deep question:
Does randomization really ever help us, in P(TIME) vs NP(TIME) problems?
Or is every problem for which randomization helps,
is there some clever PTIME algorithm we just don't know about yet?