[an error occurred while processing this directive]

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:

Yes, our function meets these criteria.

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:

  1. We take the verifier, and model it with a huge propositional formula: For every bit of memory it might potentially use during a run, we'll have a proposition for that for each of the nk time steps.
  2. Now make a bunch of formulas which relate one time-step to the next: For example, if instruction#95 were ``j ← i'', then we would have a formula ``(PC17 = 95) → (j18 ↔ i17''; this talks about time 17; we'd have another such formula talking aobut time 18, and 19, etc (each involving separate propositions).
  3. Call this mega-formula φ. It's huge, but it's still polynomial in the input length. Note that the value of the input-bits at time 0 is entirely unconstrained; after that, there are formulas constraining what the values of memory at all later times are (at least, at times up to nk).
  4. Now, just pass the question to the SAT solver, asking φ ∧ Outputnk. This solves whether or not there's some input that makes the Output bit true.

[Realize, this is very much a sketch.

See Comp 481 for more info.

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.20

Randomized Algorithms

Now, 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:

These are all trade-offs:

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?

[an error occurred while processing this directive] [an error occurred while processing this directive]