Premaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018

Size: px
Start display at page:

Download "Premaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018"

Transcription

1 Premster Course Algorithms Chpter 6: Shortest Pths Christin Scheieler SS 8

2 Bsic Grph Algorithms Overview: Shortest pths in DAGs Dijkstr s lgorithm Bellmn-For lgorithm Johnson s metho SS 8 Chpter 6

3 Shortest Pths t s Centrl question: Determine fstest wy to get from s to t. SS 8 Chpter 6 3

4 Shortest Pths Shortest Pth Prolem: irecte/unirecte grph G=(V,E) ege costs c:e R SSSP (single source shortest pth): fin shortest pths from source noe to ll other noes APSP (ll pirs shortest pth): fin shortest pths etween ll pirs of noes SS 8 Chpter 6 4

5 Shortest Pths s δ(s,v): istnce etween s n v no pth from s to v δ(s,v) = - pth of ritrrily low cost from s to v min{ c(p) p is pth from s to v} SS 8 Chpter 6 5

6 Shortest Pths s When is the istnce -? If there is negtive cycle: s C v c(c)< SS 8 Chpter 6 6

7 Shortest Pths Negtive cycle necessry n sufficient for istnce of -. Negtive cycle sufficient: pth q pth p s C v c(c)< Cost for i-fol trversl of C: c(p) + i c(c) + c(q) For i this expression pproches -. SS 8 Chpter 6 7

8 Shortest Pths Negtive cycle necessry n sufficient for istnce of -. Negtive cycle necessry: l: miniml cost of simple pth from s to v suppose there is non-simple pth p from s to v with cost c(r)<l p non-simple: continuously remove cycle C till we re left with simple pth p since c(p) < l ut c(p ) l ue to the efinition of l, there must e cycle C with c(c)< SS 8 Chpter 6 8

9 Shortest Pths in DAGs Directe cyclic grph (DAG): DAG with ege costs : reth-first serch ( : eges of BFS-tree) s 4 SS 8 Chpter 6 9

10 Shortest Pths in DAGs Directe cyclic grph (DAG): DAG with ritrry ege costs: reth-first serch oes not work ny more! s SS 8 Chpter

11 Shortest Pths in DAGs Directe cyclic grph (DAG): Correct istnces: s SS 8 Chpter 6

12 Shortest Pths in DAGs Ie: use the fct tht noes in DAGs cn e topologiclly sorte (i.e., ll eges stisfy <) s SS 8 Chpter 6

13 Shortest Pths in DAGs Initilly, set the istnce [s] to n the istnces [v] of ll other noes v to SS 8 Chpter 6 3

14 Shortest Pths in DAGs Next, consier the noes u in the orer of the topologicl sorting n perform istnce upte for u. s SS 8 Chpter 6 4

15 Shortest Pths in DAGs Distnce upte for noe u: for ll eges (u,v) E, set [v] to min{[v],[u]+c(u,v)}. s SS 8 Chpter 6 5

16 Shortest Pths in DAGs Summry: First, compute topologicl sort of the noes (cn e one vi DFS). Then, upte the istnces in the orer of the topologicl sort of the noes. Runtime: O( V + E ). Why oes tht work? SS 8 Chpter 6 6

17 Shortest Pths in DAGs Consier shortest pth from s to v. This hs topologicl sort with t i <t i+ for ll i. t t t 3 t 4 t 5 s 3 4 c c c 3 c 4 v A visit in topologicl orer therefore results in the correct istnces ( i = j i c i ). SS 8 Chpter 6 7

18 Shortest Pths in DAGs Consier shortest pth from s to v. This hs topologicl sort with t i <t i+ for ll i. t t t 3 t 4 t 5 s 3 4 c c c 3 c 4 v Remrk: no noe i long the shortest pth to v cn hve istnce < i to s since otherwise there is shorter pth to v. SS 8 Chpter 6 8

19 Generl Strtegy: Shortest Pths Initilly, set (s):= n (v):= for ll other noes Visit noes in n orer tht ensures tht t lest one shortest pth from s to every v is visite in the orer of its noes For every visite v, upte istnces to noes w with (v,w) E, i.e., (w):= min{(w), (v)+c(v,w)} SS 8 Chpter 6 9

20 Shortest Pths Next step: compute shortest pths for ritrry grphs with positive ege costs. Prolem: visiting noes of shortest pth in the right orer s 3 4 v Solution: visit noes in the orer of their istnce to s. SS 8 Chpter 6

21 Shortest Pths Assumption: ll ege costs re positive. (Actully, Dijkstr lso works if ege costs re non-negtive.) Dijkstr s lgorithm:. Let S e the set of lrey processe noes.. Initilly, S:={s} n [s]:= 3. while V S o 4. choose noe v V\S with t lest one ege from S n [v]:= min u S:(u,v) E [u] + c(u,v) eing miniml mong ll v V\S 5. v to S SS 8 Chpter 6

22 Shortest Pths Assumption: ll ege weights re positive. Dijkstr s lgorithm:. Let S e the set of lrey processe noes.. Initilly, S:={s} n [s]:= How to o tht efficiently?? 3. while V S o 4. choose noe v V\S with t lest one ege from S n [v]:= min u S:(u,v) E [u] + c(u,v) eing miniml mong ll v V\S 5. v to S SS 8 Chpter 6

23 Shortest Pths Assumption: ll ege weights re positive. Dijkstr s lgorithm:. Let S e the set of lrey processe noes.. Initilly, S:={s} n [s]:= 3. while V S o Use hep for tht! 4. choose noe v V\S with t lest one ege from S n [v]:= min u S:(u,v) E [u] + c(u,v) eing miniml mong ll v V\S 5. v to S SS 8 Chpter 6 3

24 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o Here, ege cost of e: w(e) 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s 7 c DK(Q,v,): DecreseKey opertion Reuces vlue [v] of v in Q to n performs hepifyup to repir hep property from position of v. SS 8 Chpter 6 4

25 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 SS 8 Chpter 6 5

26 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: s c SS 8 Chpter 6 6

27 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: s c SS 8 Chpter 6 7

28 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: c SS 8 Chpter 6 8

29 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: c SS 8 Chpter 6 9

30 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: c SS 8 Chpter 6 3

31 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: c SS 8 Chpter 6 3

32 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 Q: c SS 8 Chpter 6 3

33 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 7 Q: c SS 8 Chpter 6 33

34 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 7 Q: c SS 8 Chpter 6 34

35 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 7 Q: c SS 8 Chpter 6 35

36 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u s c 5 7 Q: c SS 8 Chpter 6 36

37 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 7 Q: c SS 8 Chpter 6 37

38 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 7 Q: c SS 8 Chpter 6 38

39 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 39

40 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 4

41 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 4

42 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 4

43 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 43

44 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: c SS 8 Chpter 6 44

45 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 45

46 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 46

47 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 47

48 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 48

49 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 49

50 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 5

51 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c 5 4 Q: SS 8 Chpter 6 5

52 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 5

53 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 53

54 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 54

55 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 55

56 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 56

57 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q BuilHep(V) 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Q: SS 8 Chpter 6 57

58 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q V 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Runtime: Q BuilHep(V) (sets up hep): O( V ) SS 8 Chpter 6 58

59 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q V 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Runtime: eletemin un DecreseKey: O(log V ) SS 8 Chpter 6 59

60 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q V 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Runtime: eletemin: V times, DecreseKey: E times SS 8 Chpter 6 6

61 Shortest Pths Dijkstr(G,w,s). for ech vertex v V o [v] ; π[v] nil. [s] ; S ; Q V 3. while Q o 4. u eletemin(q) 5. S S {u} 6. for ech vertex v Aj[u] o 7. if [v]>[u]+w(u,v) then DK(Q,v,[u]+w(u,v)); π[v] u 4 s c Runtime: ltogether, O(( V + E ) log V ) SS 8 Chpter 6 6

62 Shortest Pths in Aritrry Grphs Generl Strtegy: Initilly, set (s):= n (v):= for ll other noes Visit noes in n orer tht ensures tht t lest one shortest pth from s to every v is visite in the orer of its noes For every visite v, upte istnces to noes w with (v,w) E, i.e., (w):= min{(w), (v)+c(v,w)} SS 8 Chpter 6 6

63 Bellmn-For Algorithm Consier grphs with ritrry ege costs. Prolem: visit noes long shortest pth from s to v in the right orer s 3 4 v Dijkstr s lgorithm cnnot e use in this cse ny more. SS 8 Chpter 6 63

64 Bellmn-For Algorithm Exmple: v - s Noe v hs wrong istnce vlue! SS 8 Chpter 6 64

65 Bellmn-For Algorithm Strtegy: visit (n-)-times ll noes in the grph n upte istnces. Then ll shortest pths hve een consiere. s 3 4 Run 3 4 v SS 8 Chpter 6 65

66 Bellmn-For Algorithm Prolem: etection of negtive cycles s Conclusion: in negtive cycle, istnce of t lest one noe keeps ecresing in ech roun, strting with roun <n SS 8 Chpter 6 66

67 Bellmn-For Algorithm Lemm : No ecrese of istnce in roun (i.e., [v]+c(v,w) [w] for ll w): Done ecuse [w]=δ(s,w) for ll w Decrese of istnce even in n-th roun (i.e., [v]+c(v,w)<[w] for some w): There re negtive cycles for ll of these noes, so noe w hs istnce δ(s,w)=-. If this is true for w, then lso for ll noes rechle from w. Proof: exercise SS 8 Chpter 6 67

68 Bellmn-For Algorithm Proceure BellmnFor(s: NoeI) :=<,, >: NoeArry of R {-, } prent:=<,, >: NoeArry of NoeI [s]:=; prent[s]:=s for i:= to n- o // upte istnces for n- rouns forll e=(v,w) E o if [w] > [v]+c(e) then // etter istnce? [w]:=[v]+c(e); prent[w]:=v forll e=(v,w) E o // still etter in n-th roun? if [w] > [v]+c(e) then infect(w) Proceure infect(v) // set - -istnce strting with v if [v]>- then [v]:=- forll (v,w) E o infect(w) SS 8 Chpter 6 68

69 Bellmn-For Algorithm Runtime: O(n m) Improvements: Check in ech upte roun if we still hve [v]+c[v,w]<[w] for some (v,w) E. No: one! Visit in ech roun only those noes w with some ege (v,w) E where [v] hs ecrese in the previous roun. SS 8 Chpter 6 69

70 All Pirs Shortest Pths Assumption: grph with ritrry ege costs, ut no negtive cycles Nive Strtegy for grph with n noes: run n times Bellmn-For Algorithm (once for every noe s the source) Runtime: O(n m) SS 8 Chpter 6 7

71 All Pirs Shortest Pths Better Strtegy: Reuce n Bellmn-For pplictions to n Dijkstr pplictions Prolem: we nee non-negtive ege costs Solution: convert ege costs into nonnegtive ege costs without chnging the shortest pths (not so esy!) SS 8 Chpter 6 7

72 All Pirs Shortest Pths Counter exmple to itive increse y c: efore cost + everywhere v 3 v s s - : shortest pth SS 8 Chpter 6 7

73 Johnson s Metho Let φ:v R e function tht ssigns potentil to every noe. The reuce cost of e=(v,w) is: r(e) := c(e) + φ(v) - φ(w) Lemm : Let p n q e pths connecting the sme enpoints in G. Then for every potentil φ: r(p)<r(q) if n only if c(p)<c(q). SS 8 Chpter 6 73

74 Johnson s Metho Lemm : Let p n q e pths connecting the sme enpoints in G. Then for every potentil φ: r(p)<r(q) if n only if c(p)<c(q). Proof: Let p=(v,,v k ) e n ritrry pth n e i =(v i,v i+ ) for ll i. It hols: r(p) = i r(e i ) = i (φ(v i ) + c(e i ) - φ(v i+ )) = φ(v ) + c(p) - φ(v k ) SS 8 Chpter 6 74

75 Johnson s Metho Lemm 3: Suppose tht G hs no negtive cycles n tht ll noes cn e reche from s. Let φ(v)=δ(s,v) for ll v V. With this φ, r(e) for ll e. Proof: Accoring to our ssumption, δ(s,v) R for ll v We know: for every ege e=(v,w), δ(s,v)+c(e) δ(s,w) (otherwise, we hve contriction to the efinition of δ!) Therefore, r(e) = δ(s,v) + c(e) - δ(s,w) SS 8 Chpter 6 75

76 Johnson s Metho. Crete new noe s n new eges (s,v) for ll v in G with c(s,v)= (ll noes rechle!). Compute δ(s,v) using Bellmn-For n set φ(v):=δ(s,v) for ll v 3. Compute the reuce costs r(e) 4. Compute for ll noes v the istnces δ(v,w) using Dijkstr with the reuce costs on grph G without noe s 5. Compute the correct istnces δ(v,w) vi δ(v,w):=δ(v,w)+φ(w)-φ(v) SS 8 Chpter 6 76

77 Johnson s Metho Exmple: c - c - SS 8 Chpter 6 77

78 Johnson s Metho Step : crete new source s s c - SS 8 Chpter 6 78

79 Johnson s Metho Step : pply Bellmn-For to s φ()= φ()= s c φ(c)=- - φ()= SS 8 Chpter 6 79

80 Johnson s Metho Step 3: compute r(e)-vlues φ()= The reuce cost of e=(v,w) is: r(e) := φ(v) + c(e) - φ(w) φ()= c φ(c)=- φ()= SS 8 Chpter 6 8

81 Johnson s Metho Step 4: compute ll istnces δ(v,w) vi Dijkstr φ()= δ c φ()= 3 3 c 3 c φ(c)=- φ()= SS 8 Chpter 6 8

82 Johnson s Metho Step 5: compute correct istnces vi the formul δ(v,w)=δ(v,w)+φ(w)-φ(v) φ()= φ()= δ c 3 c c φ(c)=- - φ()= SS 8 Chpter 6 8

83 All Pirs Shortest Pths Runtime of Johnson s Metho: O(T Bellmn-For (n,m) + n T Dijkstr (n,m)) = O(n m + n(n log n + m)) = O(n m + n log n) when using Fioncci heps. Prolem with the runtime oun: m cn e quite lrge in the worst cse (up to ~n ) Nevertheless, est known oun: O(n m) SS 8 Chpter 6 83

V = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V)

V = set of vertices (vertex / node) E = set of edges (v, w) (v, w in V) Definitions G = (V, E) V = set of verties (vertex / noe) E = set of eges (v, w) (v, w in V) (v, w) orere => irete grph (igrph) (v, w) non-orere => unirete grph igrph: w is jent to v if there is n ege from

More information

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chpter 9 Greey Tehnique Copyright 2007 Person Aison-Wesley. All rights reserve. Greey Tehnique Construts solution to n optimiztion prolem piee y piee through sequene of hoies tht re: fesile lolly optiml

More information

2 Computing all Intersections of a Set of Segments Line Segment Intersection

2 Computing all Intersections of a Set of Segments Line Segment Intersection 15-451/651: Design & Anlysis of Algorithms Novemer 14, 2016 Lecture #21 Sweep-Line nd Segment Intersection lst chnged: Novemer 8, 2017 1 Preliminries The sweep-line prdigm is very powerful lgorithmic design

More information

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig

CS311H: Discrete Mathematics. Graph Theory IV. A Non-planar Graph. Regions of a Planar Graph. Euler s Formula. Instructor: Işıl Dillig CS311H: Discrete Mthemtics Grph Theory IV Instructor: Işıl Dillig Instructor: Işıl Dillig, CS311H: Discrete Mthemtics Grph Theory IV 1/25 A Non-plnr Grph Regions of Plnr Grph The plnr representtion of

More information

Ma/CS 6b Class 1: Graph Recap

Ma/CS 6b Class 1: Graph Recap M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Adm Sheffer. Office hour: Tuesdys 4pm. dmsh@cltech.edu TA: Victor Kstkin. Office hour: Tuesdys 7pm. 1:00 Mondy, Wednesdy, nd Fridy. http://www.mth.cltech.edu/~2014-15/2term/m006/

More information

Ma/CS 6b Class 1: Graph Recap

Ma/CS 6b Class 1: Graph Recap M/CS 6 Clss 1: Grph Recp By Adm Sheffer Course Detils Instructor: Adm Sheffer. TA: Cosmin Pohot. 1pm Mondys, Wednesdys, nd Fridys. http://mth.cltech.edu/~2015-16/2term/m006/ Min ook: Introduction to Grph

More information

Today. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search.

Today. CS 188: Artificial Intelligence Fall Recap: Search. Example: Pancake Problem. Example: Pancake Problem. General Tree Search. CS 88: Artificil Intelligence Fll 00 Lecture : A* Serch 9//00 A* Serch rph Serch Tody Heuristic Design Dn Klein UC Berkeley Multiple slides from Sturt Russell or Andrew Moore Recp: Serch Exmple: Pncke

More information

The Greedy Method. The Greedy Method

The Greedy Method. The Greedy Method Lists nd Itertors /8/26 Presenttion for use with the textook, Algorithm Design nd Applictions, y M. T. Goodrich nd R. Tmssi, Wiley, 25 The Greedy Method The Greedy Method The greedy method is generl lgorithm

More information

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs.

If you are at the university, either physically or via the VPN, you can download the chapters of this book as PDFs. Lecture 5 Wlks, Trils, Pths nd Connectedness Reding: Some of the mteril in this lecture comes from Section 1.2 of Dieter Jungnickel (2008), Grphs, Networks nd Algorithms, 3rd edition, which is ville online

More information

COMP 423 lecture 11 Jan. 28, 2008

COMP 423 lecture 11 Jan. 28, 2008 COMP 423 lecture 11 Jn. 28, 2008 Up to now, we hve looked t how some symols in n lphet occur more frequently thn others nd how we cn sve its y using code such tht the codewords for more frequently occuring

More information

F. R. K. Chung y. University ofpennsylvania. Philadelphia, Pennsylvania R. L. Graham. AT&T Labs - Research. March 2,1997.

F. R. K. Chung y. University ofpennsylvania. Philadelphia, Pennsylvania R. L. Graham. AT&T Labs - Research. March 2,1997. Forced convex n-gons in the plne F. R. K. Chung y University ofpennsylvni Phildelphi, Pennsylvni 19104 R. L. Grhm AT&T Ls - Reserch Murry Hill, New Jersey 07974 Mrch 2,1997 Astrct In seminl pper from 1935,

More information

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming

Lecture 10 Evolutionary Computation: Evolution strategies and genetic programming Lecture 10 Evolutionry Computtion: Evolution strtegies nd genetic progrmming Evolution strtegies Genetic progrmming Summry Negnevitsky, Person Eduction, 2011 1 Evolution Strtegies Another pproch to simulting

More information

Position Heaps: A Simple and Dynamic Text Indexing Data Structure

Position Heaps: A Simple and Dynamic Text Indexing Data Structure Position Heps: A Simple nd Dynmic Text Indexing Dt Structure Andrzej Ehrenfeucht, Ross M. McConnell, Niss Osheim, Sung-Whn Woo Dept. of Computer Science, 40 UCB, University of Colordo t Boulder, Boulder,

More information

10.5 Graphing Quadratic Functions

10.5 Graphing Quadratic Functions 0.5 Grphing Qudrtic Functions Now tht we cn solve qudrtic equtions, we wnt to lern how to grph the function ssocited with the qudrtic eqution. We cll this the qudrtic function. Grphs of Qudrtic Functions

More information

Outline. CS38 Introduction to Algorithms. Graphs. Graphs. Graphs. Graph traversals

Outline. CS38 Introduction to Algorithms. Graphs. Graphs. Graphs. Graph traversals Outline CS38 Introution to Algorithms Leture 2 April 3, 2014 grph trversls (BFS, DFS) onnetivity topologil sort strongly onnete omponents heps n hepsort greey lgorithms April 3, 2014 CS38 Leture 2 2 Grphs

More information

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries

Tries. Yufei Tao KAIST. April 9, Y. Tao, April 9, 2013 Tries Tries Yufei To KAIST April 9, 2013 Y. To, April 9, 2013 Tries In this lecture, we will discuss the following exct mtching prolem on strings. Prolem Let S e set of strings, ech of which hs unique integer

More information

Introduction to Integration

Introduction to Integration Introduction to Integrtion Definite integrls of piecewise constnt functions A constnt function is function of the form Integrtion is two things t the sme time: A form of summtion. The opposite of differentition.

More information

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. Example: Pancake Problem. Example: Pancake Problem

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. Example: Pancake Problem. Example: Pancake Problem Announcements Project : erch It s live! Due 9/. trt erly nd sk questions. It s longer thn most! Need prtner? Come up fter clss or try Pizz ections: cn go to ny, ut hve priority in your own C 88: Artificil

More information

Pointwise convergence need not behave well with respect to standard properties such as continuity.

Pointwise convergence need not behave well with respect to standard properties such as continuity. Chpter 3 Uniform Convergence Lecture 9 Sequences of functions re of gret importnce in mny res of pure nd pplied mthemtics, nd their properties cn often be studied in the context of metric spces, s in Exmples

More information

What are suffix trees?

What are suffix trees? Suffix Trees 1 Wht re suffix trees? Allow lgorithm designers to store very lrge mount of informtion out strings while still keeping within liner spce Allow users to serch for new strings in the originl

More information

Distance vector protocol

Distance vector protocol istne vetor protool Irene Finohi finohi@i.unirom.it Routing Routing protool Gol: etermine goo pth (sequene of routers) thru network from soure to Grph strtion for routing lgorithms: grph noes re routers

More information

Presentation Martin Randers

Presentation Martin Randers Presenttion Mrtin Rnders Outline Introduction Algorithms Implementtion nd experiments Memory consumption Summry Introduction Introduction Evolution of species cn e modelled in trees Trees consist of nodes

More information

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015

Finite Automata. Lecture 4 Sections Robb T. Koether. Hampden-Sydney College. Wed, Jan 21, 2015 Finite Automt Lecture 4 Sections 3.6-3.7 Ro T. Koether Hmpden-Sydney College Wed, Jn 21, 2015 Ro T. Koether (Hmpden-Sydney College) Finite Automt Wed, Jn 21, 2015 1 / 23 1 Nondeterministic Finite Automt

More information

9 Graph Cutting Procedures

9 Graph Cutting Procedures 9 Grph Cutting Procedures Lst clss we begn looking t how to embed rbitrry metrics into distributions of trees, nd proved the following theorem due to Brtl (1996): Theorem 9.1 (Brtl (1996)) Given metric

More information

CSEP 573 Artificial Intelligence Winter 2016

CSEP 573 Artificial Intelligence Winter 2016 CSEP 573 Artificil Intelligence Winter 2016 Luke Zettlemoyer Problem Spces nd Serch slides from Dn Klein, Sturt Russell, Andrew Moore, Dn Weld, Pieter Abbeel, Ali Frhdi Outline Agents tht Pln Ahed Serch

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Winter 2016 Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence Winter 2016 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl

More information

EXPONENTIAL & POWER GRAPHS

EXPONENTIAL & POWER GRAPHS Eponentil & Power Grphs EXPONENTIAL & POWER GRAPHS www.mthletics.com.u Eponentil EXPONENTIAL & Power & Grphs POWER GRAPHS These re grphs which result from equtions tht re not liner or qudrtic. The eponentil

More information

Greedy Algorithm. Algorithm Fall Semester

Greedy Algorithm. Algorithm Fall Semester Greey Algorithm Algorithm 0 Fll Semester Optimiztion prolems An optimiztion prolem is one in whih you wnt to fin, not just solution, ut the est solution A greey lgorithm sometimes works well for optimiztion

More information

1.5 Extrema and the Mean Value Theorem

1.5 Extrema and the Mean Value Theorem .5 Extrem nd the Men Vlue Theorem.5. Mximum nd Minimum Vlues Definition.5. (Glol Mximum). Let f : D! R e function with domin D. Then f hs n glol mximum vlue t point c, iff(c) f(x) for ll x D. The vlue

More information

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards

A Tautology Checker loosely related to Stålmarck s Algorithm by Martin Richards A Tutology Checker loosely relted to Stålmrck s Algorithm y Mrtin Richrds mr@cl.cm.c.uk http://www.cl.cm.c.uk/users/mr/ University Computer Lortory New Museum Site Pemroke Street Cmridge, CB2 3QG Mrtin

More information

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. General Tree Search. Uniform Cost. Lecture 3: A* Search 9/4/2007

Announcements. CS 188: Artificial Intelligence Fall Recap: Search. Today. General Tree Search. Uniform Cost. Lecture 3: A* Search 9/4/2007 CS 88: Artificil Intelligence Fll 2007 Lecture : A* Serch 9/4/2007 Dn Klein UC Berkeley Mny slides over the course dpted from either Sturt Russell or Andrew Moore Announcements Sections: New section 06:

More information

COMBINATORIAL PATTERN MATCHING

COMBINATORIAL PATTERN MATCHING COMBINATORIAL PATTERN MATCHING Genomic Repets Exmple of repets: ATGGTCTAGGTCCTAGTGGTC Motivtion to find them: Genomic rerrngements re often ssocited with repets Trce evolutionry secrets Mny tumors re chrcterized

More information

Network Layer: Routing Classifications; Shortest Path Routing

Network Layer: Routing Classifications; Shortest Path Routing igitl ommuniction in the Modern World : Routing lssifictions; Shortest Pth Routing s min prolem: To get efficiently from one point to the other in dynmic environment http://.cs.huji.c.il/~com com@cs.huji.c.il

More information

Fig.25: the Role of LEX

Fig.25: the Role of LEX The Lnguge for Specifying Lexicl Anlyzer We shll now study how to uild lexicl nlyzer from specifiction of tokens in the form of list of regulr expressions The discussion centers round the design of n existing

More information

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES)

1. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) Numbers nd Opertions, Algebr, nd Functions 45. SEQUENCES INVOLVING EXPONENTIAL GROWTH (GEOMETRIC SEQUENCES) In sequence of terms involving eponentil growth, which the testing service lso clls geometric

More information

CSCI1950 Z Computa4onal Methods for Biology Lecture 2. Ben Raphael January 26, hhp://cs.brown.edu/courses/csci1950 z/ Outline

CSCI1950 Z Computa4onal Methods for Biology Lecture 2. Ben Raphael January 26, hhp://cs.brown.edu/courses/csci1950 z/ Outline CSCI1950 Z Comput4onl Methods for Biology Lecture 2 Ben Rphel Jnury 26, 2009 hhp://cs.brown.edu/courses/csci1950 z/ Outline Review of trees. Coun4ng fetures. Chrcter bsed phylogeny Mximum prsimony Mximum

More information

Today. Search Problems. Uninformed Search Methods. Depth-First Search Breadth-First Search Uniform-Cost Search

Today. Search Problems. Uninformed Search Methods. Depth-First Search Breadth-First Search Uniform-Cost Search Uninformed Serch [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.] Tody Serch Problems Uninformed Serch Methods

More information

Notes for Graph Theory

Notes for Graph Theory Notes for Grph Theory These re notes I wrote up for my grph theory clss in 06. They contin most of the topics typiclly found in grph theory course. There re proofs of lot of the results, ut not of everything.

More information

Suffix trees, suffix arrays, BWT

Suffix trees, suffix arrays, BWT ALGORITHMES POUR LA BIO-INFORMATIQUE ET LA VISUALISATION COURS 3 Rluc Uricru Suffix trees, suffix rrys, BWT Bsed on: Suffix trees nd suffix rrys presenttion y Him Kpln Suffix trees course y Pco Gomez Liner-Time

More information

Improper Integrals. October 4, 2017

Improper Integrals. October 4, 2017 Improper Integrls October 4, 7 Introduction We hve seen how to clculte definite integrl when the it is rel number. However, there re times when we re interested to compute the integrl sy for emple 3. Here

More information

Theory of Computation CSE 105

Theory of Computation CSE 105 $ $ $ Theory of Computtion CSE 105 Regulr Lnguges Study Guide nd Homework I Homework I: Solutions to the following problems should be turned in clss on July 1, 1999. Instructions: Write your nswers clerly

More information

Determining Single Connectivity in Directed Graphs

Determining Single Connectivity in Directed Graphs Determining Single Connectivity in Directed Grphs Adm L. Buchsbum 1 Mrtin C. Crlisle 2 Reserch Report CS-TR-390-92 September 1992 Abstrct In this pper, we consider the problem of determining whether or

More information

Chapter 2. 3/28/2004 H133 Spring

Chapter 2. 3/28/2004 H133 Spring Chpter 2 Newton believe tht light ws me up of smll prticles. This point ws ebte by scientists for mny yers n it ws not until the 1800 s when series of experiments emonstrte wve nture of light. (But be

More information

Answering Label-Constraint Reachability in Large Graphs

Answering Label-Constraint Reachability in Large Graphs Answering Lel-Constrint Rechility in Lrge Grphs Kun Xu Peking University Beijing, Chin xukun@icst.pku.edu.cn Lei Chen Hong Kong Univ. of Sci. & Tech. Hong Kong, Chin leichen@cse.ust.hk Lei Zou Peking University

More information

10.2 Graph Terminology and Special Types of Graphs

10.2 Graph Terminology and Special Types of Graphs 10.2 Grph Terminology n Speil Types of Grphs Definition 1. Two verties u n v in n unirete grph G re lle jent (or neighors) in G iff u n v re enpoints of n ege e of G. Suh n ege e is lle inient with the

More information

Tree Structured Symmetrical Systems of Linear Equations and their Graphical Solution

Tree Structured Symmetrical Systems of Linear Equations and their Graphical Solution Proceedings of the World Congress on Engineering nd Computer Science 4 Vol I WCECS 4, -4 October, 4, Sn Frncisco, USA Tree Structured Symmetricl Systems of Liner Equtions nd their Grphicl Solution Jime

More information

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley

AI Adjacent Fields. This slide deck courtesy of Dan Klein at UC Berkeley AI Adjcent Fields Philosophy: Logic, methods of resoning Mind s physicl system Foundtions of lerning, lnguge, rtionlity Mthemtics Forml representtion nd proof Algorithms, computtion, (un)decidility, (in)trctility

More information

Orthogonal line segment intersection

Orthogonal line segment intersection Computtionl Geometry [csci 3250] Line segment intersection The prolem (wht) Computtionl Geometry [csci 3250] Orthogonl line segment intersection Applictions (why) Algorithms (how) A specil cse: Orthogonl

More information

CS 221: Artificial Intelligence Fall 2011

CS 221: Artificial Intelligence Fall 2011 CS 221: Artificil Intelligence Fll 2011 Lecture 2: Serch (Slides from Dn Klein, with help from Sturt Russell, Andrew Moore, Teg Grenger, Peter Norvig) Problem types! Fully observble, deterministic! single-belief-stte

More information

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence

Solving Problems by Searching. CS 486/686: Introduction to Artificial Intelligence Solving Prolems y Serching CS 486/686: Introduction to Artificil Intelligence 1 Introduction Serch ws one of the first topics studied in AI - Newell nd Simon (1961) Generl Prolem Solver Centrl component

More information

Some necessary and sufficient conditions for two variable orthogonal designs in order 44

Some necessary and sufficient conditions for two variable orthogonal designs in order 44 University of Wollongong Reserch Online Fculty of Informtics - Ppers (Archive) Fculty of Engineering n Informtion Sciences 1998 Some necessry n sufficient conitions for two vrile orthogonl esigns in orer

More information

MATH 25 CLASS 5 NOTES, SEP

MATH 25 CLASS 5 NOTES, SEP MATH 25 CLASS 5 NOTES, SEP 30 2011 Contents 1. A brief diversion: reltively prime numbers 1 2. Lest common multiples 3 3. Finding ll solutions to x + by = c 4 Quick links to definitions/theorems Euclid

More information

Network Interconnection: Bridging CS 571 Fall Kenneth L. Calvert All rights reserved

Network Interconnection: Bridging CS 571 Fall Kenneth L. Calvert All rights reserved Network Interconnection: Bridging CS 57 Fll 6 6 Kenneth L. Clvert All rights reserved The Prolem We know how to uild (rodcst) LANs Wnt to connect severl LANs together to overcome scling limits Recll: speed

More information

An Algorithm for Enumerating All Maximal Tree Patterns Without Duplication Using Succinct Data Structure

An Algorithm for Enumerating All Maximal Tree Patterns Without Duplication Using Succinct Data Structure , Mrch 12-14, 2014, Hong Kong An Algorithm for Enumerting All Mximl Tree Ptterns Without Dupliction Using Succinct Dt Structure Yuko ITOKAWA, Tomoyuki UCHIDA nd Motoki SANO Astrct In order to extrct structured

More information

Lexical Analysis: Constructing a Scanner from Regular Expressions

Lexical Analysis: Constructing a Scanner from Regular Expressions Lexicl Anlysis: Constructing Scnner from Regulr Expressions Gol Show how to construct FA to recognize ny RE This Lecture Convert RE to n nondeterministic finite utomton (NFA) Use Thompson s construction

More information

Hyperbolas. Definition of Hyperbola

Hyperbolas. Definition of Hyperbola CHAT Pre-Clculus Hyperols The third type of conic is clled hyperol. For n ellipse, the sum of the distnces from the foci nd point on the ellipse is fixed numer. For hyperol, the difference of the distnces

More information

Efficient Algorithms For Optimizing Policy-Constrained Routing

Efficient Algorithms For Optimizing Policy-Constrained Routing Efficient Algorithms For Optimizing Policy-Constrined Routing Andrew R. Curtis curtis@cs.colostte.edu Ross M. McConnell rmm@cs.colostte.edu Dn Mssey mssey@cs.colostte.edu Astrct Routing policies ply n

More information

Union-Find Problem. Using Arrays And Chains. A Set As A Tree. Result Of A Find Operation

Union-Find Problem. Using Arrays And Chains. A Set As A Tree. Result Of A Find Operation Union-Find Problem Given set {,,, n} of n elements. Initilly ech element is in different set. ƒ {}, {},, {n} An intermixed sequence of union nd find opertions is performed. A union opertion combines two

More information

CSCI 446: Artificial Intelligence

CSCI 446: Artificial Intelligence CSCI 446: Artificil Intelligence Serch Instructor: Michele Vn Dyne [These slides were creted by Dn Klein nd Pieter Abbeel for CS188 Intro to AI t UC Berkeley. All CS188 mterils re vilble t http://i.berkeley.edu.]

More information

From Dependencies to Evaluation Strategies

From Dependencies to Evaluation Strategies From Dependencies to Evlution Strtegies Possile strtegies: 1 let the user define the evlution order 2 utomtic strtegy sed on the dependencies: use locl dependencies to determine which ttriutes to compute

More information

Section 10.4 Hyperbolas

Section 10.4 Hyperbolas 66 Section 10.4 Hyperbols Objective : Definition of hyperbol & hyperbols centered t (0, 0). The third type of conic we will study is the hyperbol. It is defined in the sme mnner tht we defined the prbol

More information

APPLICATIONS OF INTEGRATION

APPLICATIONS OF INTEGRATION Chpter 3 DACS 1 Lok 004/05 CHAPTER 5 APPLICATIONS OF INTEGRATION 5.1 Geometricl Interprettion-Definite Integrl (pge 36) 5. Are of Region (pge 369) 5..1 Are of Region Under Grph (pge 369) Figure 5.7 shows

More information

1 Quad-Edge Construction Operators

1 Quad-Edge Construction Operators CS48: Computer Grphics Hndout # Geometric Modeling Originl Hndout #5 Stnford University Tuesdy, 8 December 99 Originl Lecture #5: 9 November 99 Topics: Mnipultions with Qud-Edge Dt Structures Scribe: Mike

More information

P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have

P(r)dr = probability of generating a random number in the interval dr near r. For this probability idea to make sense we must have Rndom Numers nd Monte Crlo Methods Rndom Numer Methods The integrtion methods discussed so fr ll re sed upon mking polynomil pproximtions to the integrnd. Another clss of numericl methods relies upon using

More information

Companion Mathematica Notebook for "What is The 'Equal Weight View'?"

Companion Mathematica Notebook for What is The 'Equal Weight View'? Compnion Mthemtic Notebook for "Wht is The 'Equl Weight View'?" Dvid Jehle & Brnden Fitelson July 9 The methods used in this notebook re specil cses of more generl decision procedure

More information

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona CSc 453 Compilers nd Systems Softwre 4 : Lexicl Anlysis II Deprtment of Computer Science University of Arizon collerg@gmil.com Copyright c 2009 Christin Collerg Implementing Automt NFAs nd DFAs cn e hrd-coded

More information

Before We Begin. Introduction to Spatial Domain Filtering. Introduction to Digital Image Processing. Overview (1): Administrative Details (1):

Before We Begin. Introduction to Spatial Domain Filtering. Introduction to Digital Image Processing. Overview (1): Administrative Details (1): Overview (): Before We Begin Administrtive detils Review some questions to consider Winter 2006 Imge Enhncement in the Sptil Domin: Bsics of Sptil Filtering, Smoothing Sptil Filters, Order Sttistics Filters

More information

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona

Implementing Automata. CSc 453. Compilers and Systems Software. 4 : Lexical Analysis II. Department of Computer Science University of Arizona Implementing utomt Sc 5 ompilers nd Systems Softwre : Lexicl nlysis II Deprtment of omputer Science University of rizon collerg@gmil.com opyright c 009 hristin ollerg NFs nd DFs cn e hrd-coded using this

More information

MTH 146 Conics Supplement

MTH 146 Conics Supplement 105- Review of Conics MTH 146 Conics Supplement In this section we review conics If ou ne more detils thn re present in the notes, r through section 105 of the ook Definition: A prol is the set of points

More information

Ray surface intersections

Ray surface intersections Ry surfce intersections Some primitives Finite primitives: polygons spheres, cylinders, cones prts of generl qudrics Infinite primitives: plnes infinite cylinders nd cones generl qudrics A finite primitive

More information

Unit 5 Vocabulary. A function is a special relationship where each input has a single output.

Unit 5 Vocabulary. A function is a special relationship where each input has a single output. MODULE 3 Terms Definition Picture/Exmple/Nottion 1 Function Nottion Function nottion is n efficient nd effective wy to write functions of ll types. This nottion llows you to identify the input vlue with

More information

6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it.

6.3 Volumes. Just as area is always positive, so is volume and our attitudes towards finding it. 6.3 Volumes Just s re is lwys positive, so is volume nd our ttitudes towrds finding it. Let s review how to find the volume of regulr geometric prism, tht is, 3-dimensionl oject with two regulr fces seprted

More information

Small Business Networking

Small Business Networking Why network is n essentil productivity tool for ny smll business Effective technology is essentil for smll businesses looking to increse the productivity of their people nd business. Introducing technology

More information

Typing with Weird Keyboards Notes

Typing with Weird Keyboards Notes Typing with Weird Keyords Notes Ykov Berchenko-Kogn August 25, 2012 Astrct Consider lnguge with n lphet consisting of just four letters,,,, nd. There is spelling rule tht sys tht whenever you see n next

More information

12-B FRACTIONS AND DECIMALS

12-B FRACTIONS AND DECIMALS -B Frctions nd Decimls. () If ll four integers were negtive, their product would be positive, nd so could not equl one of them. If ll four integers were positive, their product would be much greter thn

More information

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus Unit #9 : Definite Integrl Properties, Fundmentl Theorem of Clculus Gols: Identify properties of definite integrls Define odd nd even functions, nd reltionship to integrl vlues Introduce the Fundmentl

More information

Lecture 7: Integration Techniques

Lecture 7: Integration Techniques Lecture 7: Integrtion Techniques Antiderivtives nd Indefinite Integrls. In differentil clculus, we were interested in the derivtive of given rel-vlued function, whether it ws lgeric, eponentil or logrithmic.

More information

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe

CSCI 104. Rafael Ferreira da Silva. Slides adapted from: Mark Redekopp and David Kempe CSCI 0 fel Ferreir d Silv rfsilv@isi.edu Slides dpted from: Mrk edekopp nd Dvid Kempe LOG STUCTUED MEGE TEES Series Summtion eview Let n = + + + + k $ = #%& #. Wht is n? n = k+ - Wht is log () + log ()

More information

Suffix Tries. Slides adapted from the course by Ben Langmead

Suffix Tries. Slides adapted from the course by Ben Langmead Suffix Tries Slides dpted from the course y Ben Lngmed en.lngmed@gmil.com Indexing with suffixes Until now, our indexes hve een sed on extrcting sustrings from T A very different pproch is to extrct suffixes

More information

Chapter 16. Shortest Paths Shortest Weighted Paths

Chapter 16. Shortest Paths Shortest Weighted Paths Chpter 6 Shortet Pth Given grph where ege re lle with weight (or itne) n oure vertex, wht i the hortet pth etween the oure n ome other vertex? Prolem requiring u to nwer uh querie re roly known hortet-pth

More information

Dr. D.M. Akbar Hussain

Dr. D.M. Akbar Hussain Dr. D.M. Akr Hussin Lexicl Anlysis. Bsic Ide: Red the source code nd generte tokens, it is similr wht humns will do to red in; just tking on the input nd reking it down in pieces. Ech token is sequence

More information

2-3 search trees red-black BSTs B-trees

2-3 search trees red-black BSTs B-trees 2-3 serch trees red-lck BTs B-trees 3 2-3 tree llow 1 or 2 keys per node. 2-node: one key, two children. 3-node: two keys, three children. ymmetric order. Inorder trversl yields keys in scending order.

More information

Uninformed Search. Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 31 Jan 2012

Uninformed Search. Hal Daumé III. Computer Science University of Maryland CS 421: Introduction to Artificial Intelligence 31 Jan 2012 1 Hl Dumé III (me@hl3.nme) Uninformed Serch Hl Dumé III Comuter Science University of Mrylnd me@hl3.nme CS 421: Introduction to Artificil Intelligence 31 Jn 2012 Mny slides courtesy of Dn Klein, Sturt

More information

1.1. Interval Notation and Set Notation Essential Question When is it convenient to use set-builder notation to represent a set of numbers?

1.1. Interval Notation and Set Notation Essential Question When is it convenient to use set-builder notation to represent a set of numbers? 1.1 TEXAS ESSENTIAL KNOWLEDGE AND SKILLS Prepring for 2A.6.K, 2A.7.I Intervl Nottion nd Set Nottion Essentil Question When is it convenient to use set-uilder nottion to represent set of numers? A collection

More information

Compression Outline :Algorithms in the Real World. Lempel-Ziv Algorithms. LZ77: Sliding Window Lempel-Ziv

Compression Outline :Algorithms in the Real World. Lempel-Ziv Algorithms. LZ77: Sliding Window Lempel-Ziv Compression Outline 15-853:Algorithms in the Rel World Dt Compression III Introduction: Lossy vs. Lossless, Benchmrks, Informtion Theory: Entropy, etc. Proility Coding: Huffmn + Arithmetic Coding Applictions

More information

Small Business Networking

Small Business Networking Why network is n essentil productivity tool for ny smll business Effective technology is essentil for smll businesses looking to increse the productivity of their people nd processes. Introducing technology

More information

CS481: Bioinformatics Algorithms

CS481: Bioinformatics Algorithms CS481: Bioinformtics Algorithms Cn Alkn EA509 clkn@cs.ilkent.edu.tr http://www.cs.ilkent.edu.tr/~clkn/teching/cs481/ EXACT STRING MATCHING Fingerprint ide Assume: We cn compute fingerprint f(p) of P in

More information

Midterm 2 Sample solution

Midterm 2 Sample solution Nme: Instructions Midterm 2 Smple solution CMSC 430 Introduction to Compilers Fll 2012 November 28, 2012 This exm contins 9 pges, including this one. Mke sure you hve ll the pges. Write your nme on the

More information

A dual of the rectangle-segmentation problem for binary matrices

A dual of the rectangle-segmentation problem for binary matrices A dul of the rectngle-segmenttion prolem for inry mtrices Thoms Klinowski Astrct We consider the prolem to decompose inry mtrix into smll numer of inry mtrices whose -entries form rectngle. We show tht

More information

arxiv: v1 [math.co] 18 Sep 2015

arxiv: v1 [math.co] 18 Sep 2015 Improvements on the density o miml -plnr grphs rxiv:509.05548v [mth.co] 8 Sep 05 János Brát MTA-ELTE Geometric nd Algeric Comintorics Reserch Group rt@cs.elte.hu nd Géz Tóth Alréd Rényi Institute o Mthemtics,

More information

Algorithm Design (5) Text Search

Algorithm Design (5) Text Search Algorithm Design (5) Text Serch Tkshi Chikym School of Engineering The University of Tokyo Text Serch Find sustring tht mtches the given key string in text dt of lrge mount Key string: chr x[m] Text Dt:

More information

13.1 Weighted Graphs and Their Representation

13.1 Weighted Graphs and Their Representation Chpter Shortet Pth In thi hpter we will over prolem involving fining the hortet pth etween vertie in grph with weight (length) on the ege. One oviou pplition i in fining the hortet route from one re to

More information

4/29/18 FIBONACCI NUMBERS GOLDEN RATIO, RECURRENCES. Fibonacci function. Fibonacci (Leonardo Pisano) ? Statue in Pisa Italy

4/29/18 FIBONACCI NUMBERS GOLDEN RATIO, RECURRENCES. Fibonacci function. Fibonacci (Leonardo Pisano) ? Statue in Pisa Italy /9/8 Fioncci (Leonrdo Pisno) -? Sttue in Pis Itly FIBONACCI NUERS GOLDEN RATIO, RECURRENCES Lecture CS Spring 8 Fioncci function fi() fi() fi(n) fi(n-) + fi(n-) for n,,,,,, 8,,, In his ook in titled Lier

More information

12/9/14. CS151 Fall 20124Lecture (almost there) 12/6. Graphs. Seven Bridges of Königsberg. Leonard Euler

12/9/14. CS151 Fall 20124Lecture (almost there) 12/6. Graphs. Seven Bridges of Königsberg. Leonard Euler CS5 Fll 04Leture (lmost there) /6 Seven Bridges of Königserg Grphs Prof. Tny Berger-Wolf Leonrd Euler 707-783 Is it possile to wlk with route tht rosses eh ridge e Seven Bridges of Königserg Forget unimportnt

More information

Pipeline Example: Cycle 1. Pipeline Example: Cycle 2. Pipeline Example: Cycle 4. Pipeline Example: Cycle 3. 3 instructions. 3 instructions.

Pipeline Example: Cycle 1. Pipeline Example: Cycle 2. Pipeline Example: Cycle 4. Pipeline Example: Cycle 3. 3 instructions. 3 instructions. ipeline Exmple: Cycle 1 ipeline Exmple: Cycle X X/ /W X X/ /W $3,$,$1 lw $,0($5) $3,$,$1 3 instructions 8 9 ipeline Exmple: Cycle 3 ipeline Exmple: Cycle X X/ /W X X/ /W sw $6,($7) lw $,0($5) $3,$,$1 sw

More information

arxiv: v2 [cs.dm] 17 May 2014

arxiv: v2 [cs.dm] 17 May 2014 EXTENDING ARTIAL RERESENTATIONS OF INTERVAL GRAHS. KLAVÍK, J. KRATOCHVÍL, Y. OTACHI, T. SAITOH, AND T. VYSKOČIL rxiv:1306.2182v2 [cs.dm] 17 My 2014 Astrct. Intervl grphs re intersection grphs of closed

More information

Improved Fast Replanning for Robot Navigation in Unknown Terrain

Improved Fast Replanning for Robot Navigation in Unknown Terrain Improved Fst Replnning for Robot Nvigtion in Unknown Terrin ollege of omputing Georgi Institute of Technology tlnt, G 0-00 GIT-OGSI-00/ Sven Koenig ollege of omputing Georgi Institute of Technology tlnt,

More information

Regular Expression Matching with Multi-Strings and Intervals. Philip Bille Mikkel Thorup

Regular Expression Matching with Multi-Strings and Intervals. Philip Bille Mikkel Thorup Regulr Expression Mtching with Multi-Strings nd Intervls Philip Bille Mikkel Thorup Outline Definition Applictions Previous work Two new problems: Multi-strings nd chrcter clss intervls Algorithms Thompson

More information

A Heuristic Approach for Discovering Reference Models by Mining Process Model Variants

A Heuristic Approach for Discovering Reference Models by Mining Process Model Variants A Heuristic Approch for Discovering Reference Models by Mining Process Model Vrints Chen Li 1, Mnfred Reichert 2, nd Andres Wombcher 3 1 Informtion System Group, University of Twente, The Netherlnds lic@cs.utwente.nl

More information

Stack. A list whose end points are pointed by top and bottom

Stack. A list whose end points are pointed by top and bottom 4. Stck Stck A list whose end points re pointed by top nd bottom Insertion nd deletion tke plce t the top (cf: Wht is the difference between Stck nd Arry?) Bottom is constnt, but top grows nd shrinks!

More information