Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to Computer Algorithms Lecture 21 Phillip G. Bradford Computer Science University of Alabama.

Similar presentations


Presentation on theme: "Intro to Computer Algorithms Lecture 21 Phillip G. Bradford Computer Science University of Alabama."— Presentation transcript:

1 Intro to Computer Algorithms Lecture 21 Phillip G. Bradford Computer Science University of Alabama

2 Announcements Advisory Board’s Industrial Talk Series http://www.cs.ua.edu/9IndustrialSeries.shtm 2-Dec: Mike Thomas, CIO, Gulf States Paper

3 Computer Security Research Group Meets every Friday from 11:00 to 12:00 In 112 Houser Computer Security, etc. Email me to be on the mailing list!

4 CS Story Time Prof. Jones’ research group See http://cs.ua.edu/StoryHourSlide.pdfhttp://cs.ua.edu/StoryHourSlide.pdf

5 Next Midterm Tuesday before Thanksgiving ! 25-November

6 Outline Dijkstra’s Algorithm The Single-source shortest path challenge Start talking about Huffman trees Introduction to Complexity Theory

7 Dijkstra’s Algorithm in Detail Recall the intuition Sort of like Prim’s Algorithm Fringe and shortest paths Main Invariant: once an element is absorbed from the fringe, then we have its shortest path See “S” in the next algorithm

8 Dijkstra’s Algorithm Init-Single-Source(G,w,s) S  emptyset; Q  V[G] While Q not empty do u  extractMin(Q) S  S union { u } For all v in adj[u] do Relax(u,v,w)

9 Dijkstra’s Algorithm Init-Single-Source(G,w,s) Set all vertex distance estimates to Infinity Relax(u,v,w): If d u +w(u,v) < d v then d v  d u +w(u,v) Decrease(Q,v,d v )

10 The Cost of Dijkstra’s Algorithm Example at the board We relax each edge once The decrease-key operation and the extractmin operations cost O(log |V|) Therefore, Dijkstra’s algorithm costs O(|E| log |V|) Where might there be room for improvement?

11 Huffman Trees Fixed length encodings Prefix free Prefix Trees Left edges labeled with 0 Right edges labeled with 1 How can we make sure short encodings represent common letters?

12 Huffman’s Algorithm Greedy method starting with one-node trees Merge least-weight trees, label the root with the sub tree sums Example in lecture!

13 Algorithm Design Paradigms vs. Apparently Very Hard Problems Lower bounds for problems Upper bounds for algorithms How about problems that just `seem’ hard?

14 Church-Turing Thesis What is our model of computation? How can we prove facts about computation using this model? Turing Machine Equivalent, within polynomial time, to all other `reasonable’ proposed computation

15 Determinism and Non- Determinism Deterministic algorithms Classical idea from Church-Turing Every action is directly from a consequence Non-Deterministic algorithms Guessing actions Verifying guessed solution deterministically

16 NP and P P is all decision problems solvable in deterministic polynomial time NP is all decision problems solvable in Non-deterministic polynomial time Certainly, P subset NP What about the other way?

17 P vs. NP is a big deal in all of Engineering and Science Clay Institute $1 million to solve this challenge

18 Cook-Levin Theorem CNF-SAT (x 1 or NOT(x 2 ) or x 3 ) AND (NOT(x 1 ) or x 2 ) AND… Truth assignments How hard CNF-SAT be? All (decision) problems in NP are polynomially reducible to CNF-SAT

19 Tractable and Intractable O(2 n ) intractable for even modest n assuming the Church-Turing thesis O(n 100 ) is `tractable’ given large n Seems strange… Say n=10 6 or 1 million Then (10 6 ) 100 = 10 600 is certainly not computable in any reasonable sense!

20 Hypothetical Relationships P NP-Comp. NP


Download ppt "Intro to Computer Algorithms Lecture 21 Phillip G. Bradford Computer Science University of Alabama."

Similar presentations


Ads by Google