820 likes | 986 Views
233-234. chazelle@cs.princeton.edu. Sedgewick & Wayne (2004); Chazelle (2005). theory. experimentation. computation. theory. experimentation. 1950. computation. theory. experimentation. 2005. computation. experimentation. theory. 2005. computation. Moore’s Law. No Moore’s Law
E N D
233-234 chazelle@cs.princeton.edu Sedgewick & Wayne (2004); Chazelle (2005)
theory experimentation computation
theory experimentation 1950... computation
theory experimentation 2005... computation
experimentation theory 2005 computation Moore’s Law
No Moore’s Law there ! Inverse Moore’s Law?
1. Power of algorithms 2. Duality: data & programs 3. Recursion
A program in C /**/char q='"',*a="*//**/char q='%c',*a=%c%s%c*/};)b(stup;]d[b=]d-472[b)--d(elihw;)q,a,q,q,2+a,b(ftnirps;)b(stup{)(niam;731=d tni;]572[b,",b[275];int d=137;main(){puts(b);sprintf(b,a+2,q,q,a,q);while(d--)b[274-d]=b[d];puts(b);}/*c%s%c%=a*,'c%'=q rahc/**//*"=a*,'"'=q rahc/**/ (By Dan Hoey) palindrome
A program in C char*s="char*s=%c%s%c;void main(){ printf(s,34,s,34);}";void main(){printf(s,34,s,34);}
A program in php <?php $s='<?php $s=%c%s%c; printf($s,39,$s,39); ?>'; printf ($s,39,$s,39); ?>
A program in perl $s="$s=%c%s%c;printf$s,34,$s,34;";printf$s,34,$s,34;
A program in python l='l=%s;print l%%`l`';print l%`l`
A program in Java class S{public static void main(String[]a){String s="class S{ public static void main(String[]a){String s=;char c=34; System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}"; char c=34; System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}} Output = ? class S{public static void main(String[]a){String s="class S{ public static void main(String[]a){String s=;char c=34; System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}"; char c=34; System.out.println(s.substring(0,52)+c+s+c+s.substring(52));}}
A Print next statement twice B Why does Schroedinger hate cats? Output = ? Why does Schroedinger hate cats? Why does Schroedinger hate cats? AB BB
AA AA Set B=A Print next statement twice Print next statement twice Output = ? Print next statement twice Print next statement twice
Babbage (1820) input data output data program data Rogozhin (1996) : 24 states
Print next statement twice Why does Schroedinger hate cats? Print next statement twice Print next statement twice recursion
duality Print next statement twice Print next statement twice recursion
Self-reproduction = duality + recursion
duality gene - protein dble-stranded recursion http://www.accessexcellence.org/RC/VL/GG/dna_replicating.html
What is the difference between classical math and computer science ?
Protein Interaction Network Jeong et al
Adjacency List Implementation publicclass Graph { privateint V; private Node[] adj; privateint[] degree; privatestaticclass Node { int vertex; Node next; Node(int v, Node next) { this.vertex = v; this.next = next; } } Node next vertex
Adjacency List Implementation publicclass Graph { privateint V; private Node[] adj; privateint[] degree; privatestaticclass Node { int vertex; Node next; Node(int v, Node next) { this.vertex = v; this.next = next; } } public Graph(int V) { this.V = V; adj =new Node[V]; degree =newint[V]; } graph on V verticeswith no edges Node Node Node Node Node Node
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list w v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list w v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list w v x y z w
Adjacency List Implementation publicint V() { return V; } publicvoid addEdge(int v,int w) { adj[v]=new Node(w, adj[v]); adj[w]=new Node(v, adj[w]); degree[v]++; degree[w]++; } # vertices add w to v's adjacency listadd v to w's adjacency list v w x y z w
Return list of neighbors of v as an array publicint[] neighbors(int v) { int[] neighbors =newint[degree[v]]; int i =0; for(Node x = adj[v]; x !=null; x = x.next) neighbors[i++]= x.vertex; return neighbors; } x x v a b c null d i= 0 i= 1 i= 2 i= 3 d b c a adj neighbors
Hansel & Gretel random walk 1. Birds eat the bread crumbs DFS/BFS 2. They don’t
Random walk Diffusion equation Normal distribution 3 views of the same thing
Hansel & Gretel With bread crumbs one can find exit in time proportional to V+E DFS/BFS
Undirected Depth First Search A H I B C G Adjacency Lists A: F C B GB: AC: AD: F EE: G F DF: A E D:G: E A:H: I:I: H: D E F
Undirected Depth First Search A H I B C G D E F newly discovered F visit(A) (A, F) (A, C) (A, B) (A, G) Stack
Undirected Depth First Search A H I A alreadymarked B C G D E visit(F) (F, A) (F, E) (F, D) F visit(A) (A, F) (A, C) (A, B) (A, G) Stack