1 / 20

Intro to Computer Algorithms Lecture 21

This lecture covers Dijkstra's algorithm for finding the shortest path and introduces Huffman trees for efficient encoding. It also explores complexity theory, the Church-Turing thesis, and the P vs NP problem.

heunice
Download Presentation

Intro to Computer Algorithms Lecture 21

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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.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 du+w(u,v) < dv then • dv du+w(u,v) • Decrease(Q,v,dv)

  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 • (x1 or NOT(x2) or x3) AND (NOT(x1) or x2) AND… • Truth assignments • How hard CNF-SAT be? • All (decision) problems in NP are polynomially reducible to CNF-SAT

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

  20. Hypothetical Relationships NP-Comp. NP P

More Related