SlideServe
Menu
Préférences
© SlideServe · v2026

Intro to Computer Algorithms Lecture 17

koko avatar
18 diapositives · 344 Views · Sep 15, 2014

Intro to Computer Algorithms Lecture 17. Phillip G. Bradford Computer Science University of Alabama. Announcements. Advisory Board’s Industrial Talk Series http://www.cs.ua.edu/9IndustrialSeries.shtm 4-Nov: Bill Engelke, Mercedes-Benz, USA. Next Research Colloquia:

Intro to Computer Algorithms Lecture 17 - slide 1
01 / 18Intro to Computer Algorithms Lecture 17
1 / 17

Télécharger la présentation

Intro to Computer Algorithms Lecture 17
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Intro to Computer Algorithms Lecture 17 Phillip G. Bradford Computer Science University of Alabama

  2. Announcements • Advisory Board’s Industrial Talk Series • http://www.cs.ua.edu/9IndustrialSeries.shtm • 4-Nov: Bill Engelke, Mercedes-Benz, USA. • Next Research Colloquia: • Prof. Nael Abu-Ghazaleh • 10-Nov @ 11:00am • “Active Routing in Mobile Ad Hoc Networks”

  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

  7. Dynamic Programming • Principle of optimality • Consider any well-formed substructure s of an optimal structure S • Then s is optimal itself. • This allows the combination of well-formed substructures into optimal superstructures

  8. Dynamic ProgrammingComputing Binomial Coefficients • For i1 to n do • For j 0 to min(i,k) do • If j=0 or j=k, then • C[i,j]  1 • Else • C[i,j]  C[i-1,j-1] + C[i-1,j] • Endif • Endfor • Endfor • Return C[n,k]

  9. What does this cost? • O(nk) • How about (corrected) exercise #6 in the book? Measure rec-calls instead • Omega(nk) for k constant, n varying • For general analyses, Beware of memoization! • Analyses may not reflect running times

  10. Warshall’s and Floyd’s Algs. • Adjacency Matrices Columns (to) 1 n 2 1 2 3 Rows (from) n

  11. Transitive Closure • When We work with directed graphs • Call them digraphs • Transitive closure T of a digraph is an nxn boolean matrix: • T[i,j]=1 iff there is a non-trivial path between nodes i and j. • T[i,j]=0 iff there is No path between nodes i and j (and i != j).

  12. Transitive Closure • All Pairs Shortest Path Problems • Different from Single Source Shortest Paths

  13. How to get a Transitive Closure? • How about DFS and BFS? • What about the principle of optimality? • The matrix R(k) is all paths with up to k intermediary nodes • R(0) is the adjacency matrix • R(1) is the adjacency matrix “along with” any paths that are extended by one using node 1. • OR…

  14. Transitive Closure via Warshall • R(2) is all shortest paths using nodes 1 and 2 as intermediaries • R(3) is all shortest paths using nodes 1,2, and 3 as intermediaries • … • R(n) is all shortest paths using nodes 1,2,…,n as intermediaries

  15. Basis for Warshall’s Algorithm • R(k)i,j = • = R(k-1)i,j OR [ R(k-1)i,k AND R(k-1)k,j ] • If R(k-1)i,j = 1, then R(k)i,j = 1 • Say R(k-1)i,j = 0, so R(k)i,j = 1 • iff R(k-1)i,k = 1 and R(k-1)k,j = 1 • Why?

  16. Warshall’s Algorithm • R(0)  Adjacency Matrix • For k  1 to n do • For i 1 to n do • For j  1 do n do • R(k)i,j R(k-1)i,j OR [ R(k-1)i,k AND R(k-1)k,j ] • Endfor • Endfor • Endfor • Return R(n)

  17. Floyd’s Algorithm • Weighted (non-directed) graph • No cycles of negative length • Looks like (Min,+) “matrix multiplication”

  18. Floyd’s Algorithm • DWeighted Adj. Matrix, augmented by Infinity • For k  1 to n do • For i  1 do n do • For j  1 to n do • D[i,j]  min{ D[i,j], D[i,k] + D[k,j] } • Endfor • Endfor • Endfor • Return D