COMP108 Algorithmic Foundations

Size: px
Start display at page:

Download "COMP108 Algorithmic Foundations"

Transcription

1 Grdy mthods Prudn Wong

2 Coin Chng Prolm Suppos w hv 3 typs of oins 10p 0p 50p Minimum numr of oins to mk 0.8, 1.0, 1.? Grdy mthod

3 Lrning outoms Undrstnd wht grdy mthod is Al to pply Kruskl s lgorithm to find minimum spnning tr Al to pply Dijkstr s lgorithm to find singlsour shortst-pths Al to pply grdy lgorithm to find solution for Knpsk prolm 3

4 Grdy mthods How to grdy? At vry stp, mk th st mov you n mk Kp going until you r don Advntgs Don t nd to py muh ffort t h stp Usully finds solution vry quikly Th solution found is usully not d Possil prolm Th solution found my NOT th st on

5 Grdy mthods - xmpls Minimum spnning tr Kruskl s lgorithm Singl-sour shortst-pths Dijkstr s lgorithm Both lgorithms find on of th BEST solutions Knpsk prolm grdy lgorithm dos NOT find th BEST solution 5

6 Kruskl s lgorithm

7 Minimum Spnning tr (MST) Givn n undirtd onntd grph G Th dgs r llld y wight Spnning tr of G tr ontining ll vrtis in G Minimum spnning tr of G spnning tr of G with minimum wight 7

8 Exmpls Grph G (dg ll is wight) d Spnning trs of G d d 1 d MST 8

9 Id of Kruskl's lgorithm - MST min-wight dg nd min-wight dg trs in forst my mrg until on singl tr formd 9

10 Kruskl s lgorithm - MST 8 7 d i h 1 g f Arrng dgs from smllst to lrgst wight (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 10

11 Kruskl s lgorithm - MST 8 11 h i 1 g d 1 f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 Choos th minimum wight dg (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 11

12 Kruskl s lgorithm - MST 8 7 d i h 1 g f Choos th nxt minimum wight dg (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 1

13 Kruskl s lgorithm - MST 8 11 h i 1 g d 1 f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 Continu s long s no yl forms (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 13

14 Kruskl s lgorithm - MST 8 11 h i 1 g d 1 f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 Continu s long s no yl forms (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 1

15 Kruskl s lgorithm - MST 8 11 h i 1 g d 1 f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 Continu s long s no yl forms (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 15

16 Kruskl s lgorithm - MST 8 11 h i 1 g d 1 f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 Continu s long s no yl forms (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 16

17 Kruskl s lgorithm - MST 8 11 h 7 8 i 7 1 g 1 (h,i) nnot inludd, othrwis, yl is formd d f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 17

18 Kruskl s lgorithm - MST 8 7 d i h 1 g f Choos th nxt minimum wight dg (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 18

19 Kruskl s lgorithm - MST 8 11 h 7 8 i 7 1 g 1 (,h) nnot inludd, othrwis, yl is formd d f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 19

20 Kruskl s lgorithm - MST 8 7 d i h 1 g f Choos th nxt minimum wight dg (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 0

21 Kruskl s lgorithm - MST 8 11 h 7 8 i 7 1 g 1 (f,) nnot inludd, othrwis, yl is formd d f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 1

22 Kruskl s lgorithm - MST 8 11 h 7 8 i 7 1 g (,h) nnot inludd, othrwis, yl is formd 1 d f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn

23 Kruskl s lgorithm - MST 8 11 h 7 8 i 7 1 g 1 (d,f) nnot inludd, othrwis, yl is formd d f 9 10 (h,g) 1 (i,) (g,f) (,) (,f) (,d) 7 (h,i) 7 (,) 8 (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn 3

24 Kruskl s lgorithm - MST (h,g) d (i,) 9 (g,f) 11 1 (,) i 7 (,f) 8 10 (,d) 7 h 1 g f (h,i) 7 (,) 8 MST is found whn ll dgs r xmind (,h) 8 (d,) 9 (f,) 10 (,h) 11 (d,f) 1 itli: hosn

25 Kruskl s lgorithm - MST Kruskl s lgorithm is grdy in th sns tht it lwys ttmpt to slt th smllst wight dg to inludd in th MST 5

26 Exris Find MST for this grph d 6 f 5 ordr of (dgs) sltion: 6

27 Psudo od // Givn n undirtd onntd grph G=(V,E) T = nd E = E whil E do gin nd pik n dg in E with minimum wight if dding to T dos not form yl thn dd to T, i.., T = T { } rmov from E', i.., E = E \ { } Tim omplxity? Cn tstd y mrking vrtis 7

28 Dijkstr s lgorithm

29 Singl-sour shortst-pths Considr (un)dirtd onntd grph G Th dgs r llld y wight Givn prtiulr vrtx lld th sour Find shortst pths from th sour to ll othr vrtis (shortst pth mns th totl wight of th pth is th smllst) 9

30 Exmpl Dirtd Grph G (dg ll is wight) is sour vrtx 5 5 d d thik lins: shortst pth dottd lins: not in shortst pth 30

31 Singl-sour shortst pths vs MST Shortst pths from Wht is th diffrn twn MST nd shortst pths from? 5 5 d 5 d MST 31

32 Algorithms for shortst pths Algorithms thr r mny lgorithms to solv this prolm, on of thm is Dijkstr s lgorithm, whih ssums th wights of dgs r non-ngtiv 3

33 Id of Dijkstr s lgorithm sour hoos th dg lding to vrtx s.t. ost of pth to sour is min Mind tht th dg ddd is NOT nssrily th minimum-ost on 33

34 Dijkstr s lgorithm Input: A dirtd onntd wightd grph G nd sour vrtx s Output: For vry vrtx v in G, find th shortst pth from s to v Dijkstr s lgorithm runs in itrtions: in th i-th itrtion, th vrtx whih is th i-th losst to s is found, for vry rmining vrtis, th urrnt shortst pth to s found so fr (this shortst pth will updtd s th lgorithm runs) 3

35 Dijkstr s lgorithm Suppos vrtx is th sour, w now show how Dijkstr s lgorithm works d f 6 6 h 19 k 35

36 Dijkstr s lgorithm Evry vrtx v kps lls: (1) th wight of th urrnt shortst pth from ; () th vrtx lding to v on tht pth, initilly s (, -) 9 15 (, -) 1 d (, -) 5 (, -) 0 30 (, -) f (, -) 6 6 (, -) h 19 k (, -) 36

37 (15, (, -) ) (, (9, ) -) (1, (, -) ) Dijkstr s lgorithm For vry nighor u of, updt th wight to th wight of (,u) nd th lding vrtx to. Choos from,, d th on with th smllst suh wight. hosn 9 15 nw vlus 1 d ing onsidrd (, -) 18 shortst pth f (, -) 6 6 (, -) h 19 k (, -) 37

38 Dijkstr s lgorithm For vry un-hosn nighor of vrtx, updt th wight nd lding vrtx. Choos from ALL un-hosn vrtis (i..,, d, h) th on with smllst wight. 9 nw vlus hosn 15 (15, ) 1 d (9, ) (1, ) ing onsidrd (, -) 18 shortst pth f (, -) 6 6 (33, (, -) ) h 19 k (, -) 38

39 Dijkstr s lgorithm If nw pth with smllst wight is disovrd,.g., for vrtis, h, th wight is updtd. Othrwis, lik vrtx d, no updt. Choos mong d,, h hosn (15, ) nw vlus 1 d (9, ) (1, ) ing onsidrd 18 (, (,-) ) shortst pth f (, -) 6 6 (33, (3, ) ) h 19 k (, -) 39

40 Dijkstr s lgorithm Rpt th produr. Aftr d is hosn, th wight of nd k is updtd. Choos mong, h, k. Nxt vrtx hosn is h (15, ) nw vlus 1 d (9, ) (1, ) ing onsidrd 18 (, (35, ) d) shortst pth hosn (3, ) f (, -) 6 6 h 19 k (59, (, -) d) 0

41 Dijkstr s lgorithm Aftr h is hosn, th wight of nd k is updtd gin. Choos mong, k. Nxt vrtx hosn is. (9, ) 9 (1, ) (15, ) d nw vlus ing onsidrd 18 hosn (35, (3, d) h) shortst pth f 11 (, -) 16 (3, ) h k (51, (59,d) h) 1

42 Dijkstr s lgorithm Aftr is hosn, th wight of f nd k is updtd gin. Choos mong f, k. Nxt vrtx hosn is f. (9, ) 9 (1, ) (15, ) d nw vlus ing onsidrd 18 (3, h) shortst pth hosn f 11 (5, (, -) ) 16 (3, ) h k (51, (50, h) )

43 Dijkstr s lgorithm Aftr f is hosn, it is NOT nssry to updt th wight of k. Th finl vrtx hosn is k. (9, ) 9 (1, ) (15, ) d nw vlus ing onsidrd 18 (3, h) shortst pth f 11 (5, ) 16 hosn (3, ) h k (50, ) 3

44 Dijkstr s lgorithm At this point, ll vrtis r hosn, nd th shortst pth from to vry vrtx is disovrd. (9, ) 9 (1, ) (15, ) d nw vlus ing onsidrd 18 (3, h) shortst pth f 11 (5, ) 16 (3, ) h k (50, )

45 Exris Shortst pths from (,-) 10 3 (,-) d (,-) 6 f (,-) (,-) 5 ordr of (dgs) sltion: Compr th solution with slid #6 5

46 Dijkstr s lgorithm To dsri th lgorithm using psudo od, w giv som nottions Eh vrtx v is llld with two lls: numri ll d(v) indits th lngth of th shortst pth from th sour to v found so fr nothr ll p(v) indits nxt-to-lst vrtx on suh pth, i.., th vrtx immditly for v on tht shortst pth 6

47 Psudo od // Givn grph G=(V,E) nd sour vrtx s for vry vrtx v in th grph do Tim omplxity? st d(v) = nd p(v) = null st d(s) = 0 nd V T = whil V \ V T do // thr is still som vrtx lft gin hoos th vrtx u in V \ V T with minimum d(u) st V T = V T { u } for vry vrtx v in V \ V T tht is nighor of u do nd if d(u) + w(u,v) < d(v) thn // shortr pth is found st d(v) = d(u) + w(u,v) nd p(v) = u 7

48 Dos Grdy lgorithm lwys rturn th st solution?

49 Knpsk Prolm Input: Givn n itms with wights w 1, w,, w n nd vlus v 1, v,, v n, nd knpsk with pity W. Output: Find th most vlul sust of itms tht n fit into th knpsk Applition: A trnsport pln is to dlivr th most vlul st of itms to rmot lotion without xding its pity 9

50 Exmpl 1 pity = 50 w = 10 v = 60 w = 0 v = 100 w = 30 v = 10 itm 1 itm itm 3 knpsk totl totl sust wight vlu φ 0 0 {1} {} {3} {1,} {1,3} {,3} 50 0 {1,,3} 60 N/A 50

51 Grdy pproh pity = 50 w = 10 v = 60 w = 0 v = 100 w = 30 v = 10 itm 1 itm itm 3 knpsk Grdy: pik th itm with th nxt lrgst vlu if totl wight pity. Rsult: itm 3 is tkn, totl vlu = 10, totl wight = 30 itm is tkn, totl vlu = 0, totl wight = 50 itm 1 nnot tkn Tim omplxity? Dos this lwys work? 51

52 Exmpl pity = 10 w = 7 v = w = 3 v = 1 w = v = 0 w = 5 v = 5 itm 1 itm itm 3 itm knpsk totl totl sust wight vlu φ 0 0 {1} 7 {} 3 1 {3} 0 {} 5 5 {1,} 10 5 {1,3} 11 N/A {1,} 1 N/A totl totl sust wight vlu {,3} 7 5 {,} 8 37 {3,} 9 65 {1,,3} 1 N/A {1,,} 15 N/A {1,3,} 16 N/A {,3,} 1 N/A {1,,3,} 19 N/A 5

53 Grdy pproh pity = 10 w = 7 v = w = 3 v = 1 w = v = 0 w = 5 v = 5 itm 1 itm itm 3 itm knpsk Grdy: pik th itm with th nxt lrgst vlu if totl wight pity. Rsult: itm 1 is tkn, totl vlu =, totl wight = 7 itm 3 nnot tkn itm nnot tkn itm is tkn, totl vlu = 5, totl wight = 10 not th st!! 53

54 Grdy pproh v/w = 6 v/w = v/w = 10 v/w = 5 pity = 10 w = 7 v = w = 3 v = 1 w = v = 0 w = 5 v = 5 itm 1 itm itm 3 itm knpsk Grdy : pik th itm with th nxt lrgst (vlu/wight) if totl wight pity. Rsult: itm 3 is tkn, totl vlu = 0, totl wight = itm 1 nnot tkn itm is tkn, totl vlu = 65, totl wight = 9 itm nnot tkn Work for Eg 1? 5

55 Grdy pproh v/w = 6 v/w=5 v/w = pity = 50 w = 10 v = 60 w = 0 v = 100 w = 30 v = 10 itm 1 itm itm 3 knpsk Grdy: pik th itm with th nxt lrgst (vlu/wight) if totl wight pity. Rsult: itm 1 is tkn, totl vlu = 60, totl wight = 10 itm is tkn, totl vlu = 160, totl wight = 30 itm 3 nnot tkn Not th st!! 55

56 Lsson Lrnd: Grdy lgorithm dos NOTlwys rturn th st solution

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

CSC Design and Analysis of Algorithms. Example: Change-Making Problem CSC 801- Dsign n Anlysis of Algorithms Ltur 11 Gry Thniqu Exmpl: Chng-Mking Prolm Givn unlimit mounts of oins of nomintions 1 > > m, giv hng for mount n with th lst numr of oins Exmpl: 1 = 25, 2 =10, =

More information

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V Unirt Grphs An unirt grph G = (V, E) V st o vrtis E st o unorr gs (v,w) whr v, w in V USE: to mol symmtri rltionships twn ntitis vrtis v n w r jnt i thr is n g (v,w) [or (w,v)] th g (v,w) is inint upon

More information

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013 CS Avn Dt Struturs n Algorithms Exm Solution Jon Turnr //. ( points) Suppos you r givn grph G=(V,E) with g wights w() n minimum spnning tr T o G. Now, suppos nw g {u,v} is to G. Dsri (in wors) mtho or

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spnning Trs Minimum Spnning Trs Problm A town hs st of houss nd st of rods A rod conncts nd only houss A rod conncting houss u nd v hs rpir cost w(u, v) Gol: Rpir nough (nd no mor) rods such tht:

More information

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs. Pths.. Eulr n Hmilton Pths.. Pth D. A pth rom s to t is squn o gs {x 0, x 1 }, {x 1, x 2 },... {x n 1, x n }, whr x 0 = s, n x n = t. D. Th lngth o pth is th numr o gs in it. {, } {, } {, } {, } {, } {,

More information

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)} s s of s Computr Sin & Enginring 423/823 Dsign n Anlysis of Ltur 03 (Chptr 22) Stphn Sott (Apt from Vinohnrn N. Vriym) s of s s r strt t typs tht r pplil to numrous prolms Cn ptur ntitis, rltionships twn

More information

CS 461, Lecture 17. Today s Outline. Example Run

CS 461, Lecture 17. Today s Outline. Example Run Prim s Algorithm CS 461, Ltur 17 Jr Si Univrsity o Nw Mxio In Prim s lgorithm, th st A mintin y th lgorithm orms singl tr. Th tr strts rom n ritrry root vrtx n grows until it spns ll th vrtis in V At h

More information

CS 241 Analysis of Algorithms

CS 241 Analysis of Algorithms CS 241 Anlysis o Algorithms Prossor Eri Aron Ltur T Th 9:00m Ltur Mting Lotion: OLB 205 Businss HW6 u lry HW7 out tr Thnksgiving Ring: Ch. 22.1-22.3 1 Grphs (S S. B.4) Grphs ommonly rprsnt onntions mong

More information

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s? MATH 3012 Finl Exm, My 4, 2006, WTT Stunt Nm n ID Numr 1. All our prts o this prolm r onrn with trnry strings o lngth n, i.., wors o lngth n with lttrs rom th lpht {0, 1, 2}.. How mny trnry wors o lngth

More information

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2

Graph Isomorphism. Graphs - II. Cayley s Formula. Planar Graphs. Outline. Is K 5 planar? The number of labeled trees on n nodes is n n-2 Grt Thortil Is In Computr Sin Vitor Amhik CS 15-251 Ltur 9 Grphs - II Crngi Mllon Univrsity Grph Isomorphism finition. Two simpl grphs G n H r isomorphi G H if thr is vrtx ijtion V H ->V G tht prsrvs jny

More information

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)} Introution Computr Sin & Enginring 423/823 Dsign n Anlysis of Algorithms Ltur 03 Elmntry Grph Algorithms (Chptr 22) Stphn Sott (Apt from Vinohnrn N. Vriym) I Grphs r strt t typs tht r pplil to numrous

More information

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example Outlin Computr Sin 33 Computtion o Minimum-Cost Spnnin Trs Prim's Alorithm Introution Mik Joson Dprtmnt o Computr Sin Univrsity o Clry Ltur #33 3 Alorithm Gnrl Constrution Mik Joson (Univrsity o Clry)

More information

CSE 373. Graphs 1: Concepts, Depth/Breadth-First Search reading: Weiss Ch. 9. slides created by Marty Stepp

CSE 373. Graphs 1: Concepts, Depth/Breadth-First Search reading: Weiss Ch. 9. slides created by Marty Stepp CSE 373 Grphs 1: Conpts, Dpth/Brth-First Srh ring: Wiss Ch. 9 slis rt y Mrty Stpp http://www.s.wshington.u/373/ Univrsity o Wshington, ll rights rsrv. 1 Wht is grph? 56 Tokyo Sttl Soul 128 16 30 181 140

More information

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem) 12/3/12 Outlin Prt 10. Grphs CS 200 Algorithms n Dt Struturs Introution Trminology Implmnting Grphs Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 1 Ciruits Cyl 2 Eulr

More information

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs Prt 10. Grphs CS 200 Algorithms n Dt Struturs 1 Introution Trminology Implmnting Grphs Outlin Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 2 Ciruits Cyl A spil yl

More information

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths Dt Strutur LECTURE Shortt pth lgorithm Proprti of hortt pth Bllmn-For lgorithm Dijktr lgorithm Chptr in th txtook (pp ). Wight grph -- rminr A wight grph i grph in whih g hv wight (ot) w(v i, v j ) >.

More information

Announcements. Not graphs. These are Graphs. Applications of Graphs. Graph Definitions. Graphs & Graph Algorithms. A6 released today: Risk

Announcements. Not graphs. These are Graphs. Applications of Graphs. Graph Definitions. Graphs & Graph Algorithms. A6 released today: Risk Grphs & Grph Algorithms Ltur CS Spring 6 Announmnts A6 rls toy: Risk Strt signing with your prtnr sp Prlim usy Not grphs hs r Grphs K 5 K, =...not th kin w mn, nywy Applitions o Grphs Communition ntworks

More information

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018 CSE 373: Mor on grphs; DFS n BFS Mihl L Wnsy, F 14, 2018 1 Wrmup Wrmup: Disuss with your nighor: Rmin your nighor: wht is simpl grph? Suppos w hv simpl, irt grph with x nos. Wht is th mximum numr of gs

More information

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes. Nm: UCA ID Numr: Stion lttr: th 61 : Disrt Struturs Finl Exm Instrutor: Ciprin nolsu You hv 180 minuts. No ooks, nots or lultors r llow. Do not us your own srth ppr. 1. (2 points h) Tru/Fls: Cirl th right

More information

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem)

Outline. Circuits. Euler paths/circuits 4/25/12. Part 10. Graphs. Euler s bridge problem (Bridges of Konigsberg Problem) 4/25/12 Outlin Prt 10. Grphs CS 200 Algorithms n Dt Struturs Introution Trminology Implmnting Grphs Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 1 2 Eulr s rig prolm

More information

CS61B Lecture #33. Administrivia: Autograder will run this evening. Today s Readings: Graph Structures: DSIJ, Chapter 12

CS61B Lecture #33. Administrivia: Autograder will run this evening. Today s Readings: Graph Structures: DSIJ, Chapter 12 Aministrivi: CS61B Ltur #33 Autogrr will run this vning. Toy s Rings: Grph Struturs: DSIJ, Chptr 12 Lst moifi: W Nov 8 00:39:28 2017 CS61B: Ltur #33 1 Why Grphs? For xprssing non-hirrhilly rlt itms Exmpls:

More information

CS200: Graphs. Graphs. Directed Graphs. Graphs/Networks Around Us. What can this represent? Sometimes we want to represent directionality:

CS200: Graphs. Graphs. Directed Graphs. Graphs/Networks Around Us. What can this represent? Sometimes we want to represent directionality: CS2: Grphs Prihr Ch. 4 Rosn Ch. Grphs A olltion of nos n gs Wht n this rprsnt? n A omputr ntwork n Astrtion of mp n Soil ntwork CS2 - Hsh Tls 2 Dirt Grphs Grphs/Ntworks Aroun Us A olltion of nos n irt

More information

Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs

Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs Outlin Computr Sin 33 Computtion o Minimum-Cost Spnnin Trs Prim s Mik Joson Dprtmnt o Computr Sin Univrsity o Clry Ltur #34 Introution Min-Cost Spnnin Trs 3 Gnrl Constrution 4 5 Trmintion n Eiiny 6 Aitionl

More information

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph Intrntionl J.Mth. Comin. Vol.1(2014), 80-86 Algorithmi n NP-Compltnss Aspts of Totl Lit Domintion Numr of Grph Girish.V.R. (PES Institut of Thnology(South Cmpus), Bnglor, Krntk Stt, Ini) P.Ush (Dprtmnt

More information

Garnir Polynomial and their Properties

Garnir Polynomial and their Properties Univrsity of Cliforni, Dvis Dprtmnt of Mthmtis Grnir Polynomil n thir Proprtis Author: Yu Wng Suprvisor: Prof. Gorsky Eugny My 8, 07 Grnir Polynomil n thir Proprtis Yu Wng mil: uywng@uvis.u. In this ppr,

More information

Solutions for HW11. Exercise 34. (a) Use the recurrence relation t(g) = t(g e) + t(g/e) to count the number of spanning trees of v 1

Solutions for HW11. Exercise 34. (a) Use the recurrence relation t(g) = t(g e) + t(g/e) to count the number of spanning trees of v 1 Solutions for HW Exris. () Us th rurrn rltion t(g) = t(g ) + t(g/) to ount th numr of spnning trs of v v v u u u Rmmr to kp multipl gs!! First rrw G so tht non of th gs ross: v u v Rursing on = (v, u ):

More information

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura

Module graph.py. 1 Introduction. 2 Graph basics. 3 Module graph.py. 3.1 Objects. CS 231 Naomi Nishimura Moul grph.py CS 231 Nomi Nishimur 1 Introution Just lik th Python list n th Python itionry provi wys of storing, ssing, n moifying t, grph n viw s wy of storing, ssing, n moifying t. Bus Python os not

More information

(a) v 1. v a. v i. v s. (b)

(a) v 1. v a. v i. v s. (b) Outlin RETIMING Struturl optimiztion mthods. Gionni D Mihli Stnford Unirsity Rtiming. { Modling. { Rtiming for minimum dly. { Rtiming for minimum r. Synhronous Logi Ntwork Synhronous Logi Ntwork Synhronous

More information

Announcements. These are Graphs. This is not a Graph. Graph Definitions. Applications of Graphs. Graphs & Graph Algorithms

Announcements. These are Graphs. This is not a Graph. Graph Definitions. Applications of Graphs. Graphs & Graph Algorithms Grphs & Grph Algorithms Ltur CS Fll 5 Announmnts Upoming tlk h Mny Crrs o Computr Sintist Or how Computr Sin gr mpowrs you to o muh mor thn o Dn Huttnlohr, Prossor in th Dprtmnt o Computr Sin n Johnson

More information

0.1. Exercise 1: the distances between four points in a graph

0.1. Exercise 1: the distances between four points in a graph Mth 707 Spring 2017 (Drij Grinrg): mitrm 3 pg 1 Mth 707 Spring 2017 (Drij Grinrg): mitrm 3 u: W, 3 My 2017, in lss or y mil (grinr@umn.u) or lss S th wsit or rlvnt mtril. Rsults provn in th nots, or in

More information

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths.

# 1 ' 10 ' 100. Decimal point = 4 hundred. = 6 tens (or sixty) = 5 ones (or five) = 2 tenths. = 7 hundredths. How os it work? Pl vlu o imls rprsnt prts o whol numr or ojt # 0 000 Tns o thousns # 000 # 00 Thousns Hunrs Tns Ons # 0 Diml point st iml pl: ' 0 # 0 on tnth n iml pl: ' 0 # 00 on hunrth r iml pl: ' 0

More information

Greedy Algorithms, Activity Selection, Minimum Spanning Trees Scribes: Logan Short (2015), Virginia Date: May 18, 2016

Greedy Algorithms, Activity Selection, Minimum Spanning Trees Scribes: Logan Short (2015), Virginia Date: May 18, 2016 Ltur 4 Gry Algorithms, Ativity Sltion, Minimum Spnning Trs Sris: Logn Short (5), Virgini Dt: My, Gry Algorithms Suppos w wnt to solv prolm, n w r l to om up with som rursiv ormultion o th prolm tht woul

More information

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari Grphs CSC 1300 Disrt Struturs Villnov Univrsity Grphs Grphs r isrt struturs onsis?ng of vr?s n gs tht onnt ths vr?s. Grphs n us to mol: omputr systms/ntworks mthm?l rl?ons logi iruit lyout jos/prosss f

More information

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1 CSC 00 Disrt Struturs : Introuon to Grph Thory Grphs Grphs CSC 00 Disrt Struturs Villnov Univrsity Grphs r isrt struturs onsisng o vrs n gs tht onnt ths vrs. Grphs n us to mol: omputr systms/ntworks mthml

More information

5/7/13. Part 10. Graphs. Theorem Theorem Graphs Describing Precedence. Outline. Theorem 10-1: The Handshaking Theorem

5/7/13. Part 10. Graphs. Theorem Theorem Graphs Describing Precedence. Outline. Theorem 10-1: The Handshaking Theorem Thorm 10-1: Th Hnshkin Thorm Lt G=(V,E) n unirt rph. Thn Prt 10. Grphs CS 200 Alorithms n Dt Struturs v V (v) = 2 E How mny s r thr in rph with 10 vrtis h of r six? 10 * 6 /2= 30 1 Thorm 10-2 An unirt

More information

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology! Outlin Computr Sin 331, Spnnin, n Surphs Mik Joson Dprtmnt o Computr Sin Univrsity o Clry Ltur #30 1 Introution 2 3 Dinition 4 Spnnin 5 6 Mik Joson (Univrsity o Clry) Computr Sin 331 Ltur #30 1 / 20 Mik

More information

GREEDY TECHNIQUE. Greedy method vs. Dynamic programming method:

GREEDY TECHNIQUE. Greedy method vs. Dynamic programming method: Dinition: GREEDY TECHNIQUE Gry thniqu is gnrl lgorithm sign strtgy, uilt on ollowing lmnts: onigurtions: irnt hois, vlus to in ojtiv untion: som onigurtions to ithr mximiz or minimiz Th mtho: Applil to

More information

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review rmup CSE 7: AVL trs rmup: ht is n invrint? Mihl L Friy, Jn 9, 0 ht r th AVL tr invrints, xtly? Disuss with your nighor. AVL Trs: Invrints Intrlu: Exploring th ln invrint Cor i: xtr invrint to BSTs tht

More information

Problem solving by search

Problem solving by search Prolm solving y srh Tomáš voo Dprtmnt o Cyrntis, Vision or Roots n Autonomous ystms Mrh 5, 208 / 3 Outlin rh prolm. tt sp grphs. rh trs. trtgis, whih tr rnhs to hoos? trtgy/algorithm proprtis? Progrmming

More information

CSI35 Chapter 11 Review

CSI35 Chapter 11 Review 1. Which of th grphs r trs? c f c g f c x y f z p q r 1 1. Which of th grphs r trs? c f c g f c x y f z p q r . Answr th qustions out th following tr 1) Which vrtx is th root of c th tr? ) wht is th hight

More information

Chapter 18. Minimum Spanning Trees Minimum Spanning Trees. a d. a d. a d. f c

Chapter 18. Minimum Spanning Trees Minimum Spanning Trees. a d. a d. a d. f c Chptr 8 Minimum Spnning Trs In this hptr w ovr importnt grph prolm, Minimum Spnning Trs (MST). Th MST o n unirt, wight grph is tr tht spns th grph whil minimizing th totl wight o th gs in th tr. W irst

More information

Minimum Spanning Trees

Minimum Spanning Trees Mnmum Spnnng Trs Spnnng Tr A tr (.., connctd, cyclc grph) whch contns ll th vrtcs of th grph Mnmum Spnnng Tr Spnnng tr wth th mnmum sum of wghts 1 1 Spnnng forst If grph s not connctd, thn thr s spnnng

More information

12. Traffic engineering

12. Traffic engineering lt2.ppt S-38. Introution to Tltrffi Thory Spring 200 2 Topology Pths A tlommunition ntwork onsists of nos n links Lt N not th st of nos in with n Lt J not th st of nos in with j N = {,,,,} J = {,2,3,,2}

More information

Last time: introduced our first computational model the DFA.

Last time: introduced our first computational model the DFA. Lctur 7 Homwork #7: 2.2.1, 2.2.2, 2.2.3 (hnd in c nd d), Misc: Givn: M, NFA Prov: (q,xy) * (p,y) iff (q,x) * (p,) (follow proof don in clss tody) Lst tim: introducd our first computtionl modl th DFA. Tody

More information

Final Exam Solutions

Final Exam Solutions CS 2 Advancd Data Structurs and Algorithms Final Exam Solutions Jonathan Turnr /8/20. (0 points) Suppos that r is a root of som tr in a Fionacci hap. Assum that just for a dltmin opration, r has no childrn

More information

Planar Upward Drawings

Planar Upward Drawings C.S. 252 Pro. Rorto Tmssi Computtionl Gomtry Sm. II, 1992 1993 Dt: My 3, 1993 Sri: Shmsi Moussvi Plnr Upwr Drwings 1 Thorm: G is yli i n only i it hs upwr rwing. Proo: 1. An upwr rwing is yli. Follow th

More information

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation A Simpl Co Gnrtor Co Gnrtion Chptr 8 II Gnrt o for singl si lok How to us rgistrs? In most mhin rhitturs, som or ll of th oprnsmust in rgistrs Rgistrs mk goo tmporris Hol vlus tht r omput in on si lok

More information

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1.

Why the Junction Tree Algorithm? The Junction Tree Algorithm. Clique Potential Representation. Overview. Chris Williams 1. Why th Juntion Tr lgorithm? Th Juntion Tr lgorithm hris Willims 1 Shool of Informtis, Univrsity of Einurgh Otor 2009 Th JT is gnrl-purpos lgorithm for omputing (onitionl) mrginls on grphs. It os this y

More information

Register Allocation. Register Allocation. Principle Phases. Principle Phases. Example: Build. Spills 11/14/2012

Register Allocation. Register Allocation. Principle Phases. Principle Phases. Example: Build. Spills 11/14/2012 Rgistr Allotion W now r l to o rgistr llotion on our intrfrn grph. W wnt to l with two typs of onstrints: 1. Two vlus r liv t ovrlpping points (intrfrn grph) 2. A vlu must or must not in prtiulr rhitturl

More information

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS C 24 - COMBINATIONAL BUILDING BLOCKS - INVST 3 DCODS AND NCODS FALL 23 AP FLZ To o "wll" on this invstition you must not only t th riht nswrs ut must lso o nt, omplt n onis writups tht mk ovious wht h

More information

Weighted Matching and Linear Programming

Weighted Matching and Linear Programming Wightd Mtching nd Linr Progrmming Jonthn Turnr Mrch 19, 01 W v sn tht mximum siz mtchings cn b found in gnrl grphs using ugmnting pths. In principl, this sm pproch cn b pplid to mximum wight mtchings.

More information

Register Allocation. How to assign variables to finitely many registers? What to do when it can t be done? How to do so efficiently?

Register Allocation. How to assign variables to finitely many registers? What to do when it can t be done? How to do so efficiently? Rgistr Allotion Rgistr Allotion How to ssign vrils to initly mny rgistrs? Wht to o whn it n t on? How to o so iintly? Mony, Jun 3, 13 Mmory Wll Disprity twn CPU sp n mmory ss sp improvmnt Mony, Jun 3,

More information

Seven-Segment Display Driver

Seven-Segment Display Driver 7-Smnt Disply Drivr, Ron s in 7-Smnt Disply Drivr, Ron s in Prolm 62. 00 0 0 00 0000 000 00 000 0 000 00 0 00 00 0 0 0 000 00 0 00 BCD Diits in inry Dsin Drivr Loi 4 inputs, 7 outputs 7 mps, h with 6 on

More information

Section 3: Antiderivatives of Formulas

Section 3: Antiderivatives of Formulas Chptr Th Intgrl Appli Clculus 96 Sction : Antirivtivs of Formuls Now w cn put th is of rs n ntirivtivs togthr to gt wy of vluting finit intgrls tht is ct n oftn sy. To vlut finit intgrl f(t) t, w cn fin

More information

UNCORRECTED SAMPLE PAGES 4-1. Naming fractions KEY IDEAS. 1 Each shape represents ONE whole. a i ii. b i ii

UNCORRECTED SAMPLE PAGES 4-1. Naming fractions KEY IDEAS. 1 Each shape represents ONE whole. a i ii. b i ii - Nming frtions Chptr Frtions Eh shp rprsnts ONE whol. i ii Wht frtion is shdd? Writ s frtion nd in words. Wht frtion is not shdd? Writ s frtion nd in words. i ii i ii Writ s mny diffrnt frtions s you

More information

The University of Sydney MATH2969/2069. Graph Theory Tutorial 5 (Week 12) Solutions 2008

The University of Sydney MATH2969/2069. Graph Theory Tutorial 5 (Week 12) Solutions 2008 Th Univrsity o Syny MATH2969/2069 Grph Thory Tutoril 5 (Wk 12) Solutions 2008 1. (i) Lt G th isonnt plnr grph shown. Drw its ul G, n th ul o th ul (G ). (ii) Show tht i G is isonnt plnr grph, thn G is

More information

NP-Completeness. CS3230 (Algorithm) Traveling Salesperson Problem. What s the Big Deal? Given a Problem. What s the Big Deal? What s the Big Deal?

NP-Completeness. CS3230 (Algorithm) Traveling Salesperson Problem. What s the Big Deal? Given a Problem. What s the Big Deal? What s the Big Deal? NP-Compltnss 1. Polynomil tim lgorithm 2. Polynomil tim rution 3.P vs NP 4.NP-ompltnss (som slis y P.T. Um Univrsity o Txs t Dlls r us) Trvling Slsprson Prolm Fin minimum lngth tour tht visits h ity on

More information

Constructive Geometric Constraint Solving

Constructive Geometric Constraint Solving Construtiv Gomtri Constrint Solving Antoni Soto i Rir Dprtmnt Llngutgs i Sistms Inormàtis Univrsitt Politèni Ctluny Brlon, Sptmr 2002 CGCS p.1/37 Prliminris CGCS p.2/37 Gomtri onstrint prolm C 2 D L BC

More information

Section 10.4 Connectivity (up to paths and isomorphism, not including)

Section 10.4 Connectivity (up to paths and isomorphism, not including) Toy w will isuss two stions: Stion 10.3 Rprsnting Grphs n Grph Isomorphism Stion 10.4 Conntivity (up to pths n isomorphism, not inluing) 1 10.3 Rprsnting Grphs n Grph Isomorphism Whn w r working on n lgorithm

More information

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations

More Foundations. Undirected Graphs. Degree. A Theorem. Graphs, Products, & Relations Mr Funtins Grphs, Pruts, & Rltins Unirt Grphs An unirt grph is pir f 1. A st f ns 2. A st f gs (whr n g is st f tw ns*) Friy, Sptmr 2, 2011 Ring: Sipsr 0.2 ginning f 0.4; Stughtn 1.1.5 ({,,,,}, {{,}, {,},

More information

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS

COMPLEXITY OF COUNTING PLANAR TILINGS BY TWO BARS OMPLXITY O OUNTING PLNR TILINGS Y TWO RS KYL MYR strt. W show tht th prolm o trmining th numr o wys o tiling plnr igur with horizontl n vrtil r is #P-omplt. W uil o o th rsults o uquir, Nivt, Rmil, n Roson

More information

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata CSE303 - Introduction to th Thory of Computing Smpl Solutions for Exrciss on Finit Automt Exrcis 2.1.1 A dtrministic finit utomton M ccpts th mpty string (i.., L(M)) if nd only if its initil stt is finl

More information

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016

Winter 2016 COMP-250: Introduction to Computer Science. Lecture 23, April 5, 2016 Wintr 2016 COMP-250: Introduction to Computr Scinc Lctur 23, April 5, 2016 Commnt out input siz 2) Writ ny lgorithm tht runs in tim Θ(n 2 log 2 n) in wors cs. Explin why this is its running tim. I don

More information

13. Binary tree, height 4, eight terminal vertices 14. Full binary tree, seven vertices v 7 v13. v 19

13. Binary tree, height 4, eight terminal vertices 14. Full binary tree, seven vertices v 7 v13. v 19 0. Spnning Trs n Shortst Pths 0. Consir th tr shown blow with root v 0.. Wht is th lvl of v 8? b. Wht is th lvl of v 0? c. Wht is th hight of this root tr?. Wht r th chilrn of v 0?. Wht is th prnt of v

More information

Two Graph Algorithms On an Associative Computing Model

Two Graph Algorithms On an Associative Computing Model Two Grph Algorithms On n Assoitiv Computing Modl Mingxin Jin Dprtmnt of Mthmtis nd Computr Sin Fyttvill Stt Univrsity, Fyttvill, NC 801 Emil: mjin@unfsu.du Astrt - Th MASC (for Multipl Assoitiv Computing)

More information

Spanning Tree. Preview. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree 10/17/2017.

Spanning Tree. Preview. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree 10/17/2017. 0//0 Prvw Spnnng Tr Spnnng Tr Mnmum Spnnng Tr Kruskl s Algorthm Prm s Algorthm Corrctnss of Kruskl s Algorthm A spnnng tr T of connctd, undrctd grph G s tr composd of ll th vrtcs nd som (or prhps ll) of

More information

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management nrl tr T is init st o on or mor nos suh tht thr is on sint no r, ll th root o T, n th rminin nos r prtition into n isjoint susts T, T,, T n, h o whih is tr, n whos roots r, r,, r n, rsptivly, r hilrn o

More information

QUESTIONS BEGIN HERE!

QUESTIONS BEGIN HERE! Points miss: Stunt's Nm: Totl sor: /100 points Est Tnnss Stt Univrsity Dprtmnt of Computr n Informtion Sins CSCI 710 (Trnoff) Disrt Struturs TEST for Fll Smstr, 00 R this for strtin! This tst is los ook

More information

Multi-Section Coupled Line Couplers

Multi-Section Coupled Line Couplers /0/009 MultiSction Coupld Lin Couplrs /8 Multi-Sction Coupld Lin Couplrs W cn dd multipl coupld lins in sris to incrs couplr ndwidth. Figur 7.5 (p. 6) An N-sction coupld lin l W typiclly dsign th couplr

More information

Weighted Graphs. Weighted graphs may be either directed or undirected.

Weighted Graphs. Weighted graphs may be either directed or undirected. 1 In mny ppltons, o rp s n ssot numrl vlu, ll wt. Usully, t wts r nonntv ntrs. Wt rps my tr rt or unrt. T wt o n s otn rrr to s t "ost" o t. In ppltons, t wt my msur o t lnt o rout, t pty o ln, t nry rqur

More information

1. Determine whether or not the following binary relations are equivalence relations. Be sure to justify your answers.

1. Determine whether or not the following binary relations are equivalence relations. Be sure to justify your answers. Mth 0 Exm - Prti Prolm Solutions. Dtrmin whthr or not th ollowing inry rltions r quivln rltions. B sur to justiy your nswrs. () {(0,0),(0,),(0,),(,),(,),(,),(,),(,0),(,),(,),(,0),(,),(.)} on th st A =

More information

Preview. Graph. Graph. Graph. Graph Representation. Graph Representation 12/3/2018. Graph Graph Representation Graph Search Algorithms

Preview. Graph. Graph. Graph. Graph Representation. Graph Representation 12/3/2018. Graph Graph Representation Graph Search Algorithms /3/0 Prvw Grph Grph Rprsntton Grph Srch Algorthms Brdth Frst Srch Corrctnss of BFS Dpth Frst Srch Mnmum Spnnng Tr Kruskl s lgorthm Grph Drctd grph (or dgrph) G = (V, E) V: St of vrt (nod) E: St of dgs

More information

Ch 1.2: Solutions of Some Differential Equations

Ch 1.2: Solutions of Some Differential Equations Ch 1.2: Solutions of Som Diffrntil Equtions Rcll th fr fll nd owl/mic diffrntil qutions: v 9.8.2v, p.5 p 45 Ths qutions hv th gnrl form y' = y - b W cn us mthods of clculus to solv diffrntil qutions of

More information

10/30/12. Today. CS/ENGRD 2110 Object- Oriented Programming and Data Structures Fall 2012 Doug James. DFS algorithm. Reachability Algorithms

10/30/12. Today. CS/ENGRD 2110 Object- Oriented Programming and Data Structures Fall 2012 Doug James. DFS algorithm. Reachability Algorithms 0/0/ CS/ENGRD 0 Ojt- Orint Prormmin n Dt Strutur Fll 0 Dou Jm Ltur 9: DFS, BFS & Shortt Pth Toy Rhility Dpth-Firt Srh Brth-Firt Srh Shortt Pth Unwiht rph Wiht rph Dijktr lorithm Rhility Alorithm Dpth Firt

More information

1 Introduction to Modulo 7 Arithmetic

1 Introduction to Modulo 7 Arithmetic 1 Introution to Moulo 7 Arithmti Bor w try our hn t solvin som hr Moulr KnKns, lt s tk los look t on moulr rithmti, mo 7 rithmti. You ll s in this sminr tht rithmti moulo prim is quit irnt rom th ons w

More information

Instructions for Section 1

Instructions for Section 1 Instructions for Sction 1 Choos th rspons tht is corrct for th qustion. A corrct nswr scors 1, n incorrct nswr scors 0. Mrks will not b dductd for incorrct nswrs. You should ttmpt vry qustion. No mrks

More information

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski

DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Leslie Rogalski Dut with Dimons Brlt DUET WITH DIAMONDS COLOR SHIFTING BRACELET By Lsli Roglski Photo y Anrw Wirth Supruo DUETS TM from BSmith rt olor shifting fft tht mks your work tk on lif of its own s you mov! This

More information

Multipoint Alternate Marking method for passive and hybrid performance monitoring

Multipoint Alternate Marking method for passive and hybrid performance monitoring Multipoint Altrnt Mrkin mtho or pssiv n hyri prormn monitorin rt-iool-ippm-multipoint-lt-mrk-00 Pru, Jul 2017, IETF 99 Giuspp Fiool (Tlom Itli) Muro Coilio (Tlom Itli) Amo Spio (Politnio i Torino) Riro

More information

Numbering Boundary Nodes

Numbering Boundary Nodes Numring Bounry Nos Lh MBri Empori Stt Univrsity August 10, 2001 1 Introution Th purpos of this ppr is to xplor how numring ltril rsistor ntworks ffts thir rspons mtrix, Λ. Morovr, wht n lrn from Λ out

More information

CS September 2018

CS September 2018 Loil los Distriut Systms 06. Loil los Assin squn numrs to msss All ooprtin prosss n r on orr o vnts vs. physil los: rport tim o y Assum no ntrl tim sour Eh systm mintins its own lol lo No totl orrin o

More information

DFA (Deterministic Finite Automata) q a

DFA (Deterministic Finite Automata) q a Big pictur All lngugs Dcidl Turing mchins NP P Contxt-fr Contxt-fr grmmrs, push-down utomt Rgulr Automt, non-dtrministic utomt, rgulr xprssions DFA (Dtrministic Finit Automt) 0 q 0 0 0 0 q DFA (Dtrministic

More information

Computational Biology, Phylogenetic Trees. Consensus methods

Computational Biology, Phylogenetic Trees. Consensus methods Computtionl Biology, Phylognti Trs Consnsus mthos Asgr Bruun & Bo Simonsn Th 16th of Jnury 2008 Dprtmnt of Computr Sin Th univrsity of Copnhgn 0 Motivtion Givn olltion of Trs Τ = { T 0,..., T n } W wnt

More information

Chapter 16. 1) is a particular point on the graph of the function. 1. y, where x y 1

Chapter 16. 1) is a particular point on the graph of the function. 1. y, where x y 1 Prctic qustions W now tht th prmtr p is dirctl rltd to th mplitud; thrfor, w cn find tht p. cos d [ sin ] sin sin Not: Evn though ou might not now how to find th prmtr in prt, it is lws dvisl to procd

More information

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, *

FSA. CmSc 365 Theory of Computation. Finite State Automata and Regular Expressions (Chapter 2, Section 2.3) ALPHABET operations: U, concatenation, * CmSc 365 Thory of Computtion Finit Stt Automt nd Rgulr Exprssions (Chptr 2, Sction 2.3) ALPHABET oprtions: U, conctntion, * otin otin Strings Form Rgulr xprssions dscri Closd undr U, conctntion nd * (if

More information

(Minimum) Spanning Trees

(Minimum) Spanning Trees (Mnmum) Spnnn Trs Spnnn trs Kruskl's lortm Novmr 23, 2017 Cn Hrn / Gory Tn 1 Spnnn trs Gvn G = V, E, spnnn tr o G s onnt surp o G wt xtly V 1 s mnml sust o s tt onnts ll t vrts o G G = Spnnn trs Novmr

More information

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list.

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list. 3 3 4 8 6 3 3 4 8 6 3 3 4 8 6 () (d) 3 Sarching Linkd Lists Sarching Linkd Lists Sarching Linkd Lists ssum th list is sortd, but is stord in a linkd list. an w us binary sarch? omparisons? Work? What if

More information

Graph Contraction and Connectivity

Graph Contraction and Connectivity Chptr 17 Grph Contrtion n Conntivity So r w hv mostly ovr thniqus or solving prolms on grphs tht wr vlop in th ontxt o squntil lgorithms. Som o thm r sy to prllliz whil othrs r not. For xmpl, w sw tht

More information

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued...

a b c cat CAT A B C Aa Bb Cc cat cat Lesson 1 (Part 1) Verbal lesson: Capital Letters Make The Same Sound Lesson 1 (Part 1) continued... Progrssiv Printing T.M. CPITLS g 4½+ Th sy, fun (n FR!) wy to tch cpitl lttrs. ook : C o - For Kinrgrtn or First Gr (not for pr-school). - Tchs tht cpitl lttrs mk th sm souns s th littl lttrs. - Tchs th

More information

Present state Next state Q + M N

Present state Next state Q + M N Qustion 1. An M-N lip-lop works s ollows: I MN=00, th nxt stt o th lip lop is 0. I MN=01, th nxt stt o th lip-lop is th sm s th prsnt stt I MN=10, th nxt stt o th lip-lop is th omplmnt o th prsnt stt I

More information

MAT3707. Tutorial letter 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/201/1/2017

MAT3707. Tutorial letter 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/201/1/2017 MAT3707/201/1/2017 Tutoril lttr 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS MAT3707 Smstr 1 Dprtmnt o Mtmtil Sins SOLUTIONS TO ASSIGNMENT 01 BARCODE Din tomorrow. univrsity o sout ri SOLUTIONS TO ASSIGNMENT

More information

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA.

S i m p l i f y i n g A l g e b r a SIMPLIFYING ALGEBRA. S i m p l i y i n g A l g r SIMPLIFYING ALGEBRA www.mthltis.o.nz Simpliying SIMPLIFYING Algr ALGEBRA Algr is mthmtis with mor thn just numrs. Numrs hv ix vlu, ut lgr introus vrils whos vlus n hng. Ths

More information

( ) Geometric Operations and Morphing. Geometric Transformation. Forward v.s. Inverse Mapping. I (x,y ) Image Processing - Lesson 4 IDC-CG 1

( ) Geometric Operations and Morphing. Geometric Transformation. Forward v.s. Inverse Mapping. I (x,y ) Image Processing - Lesson 4 IDC-CG 1 Img Procssing - Lsson 4 Gomtric Oprtions nd Morphing Gomtric Trnsformtion Oprtions dpnd on Pil s Coordints. Contt fr. Indpndnt of pil vlus. f f (, ) (, ) ( f (, ), f ( ) ) I(, ) I', (,) (, ) I(,) I (,

More information

Formal Concept Analysis

Formal Concept Analysis Forml Conpt Anlysis Conpt intnts s losd sts Closur Systms nd Implitions 4 Closur Systms 0.06.005 Nxt-Closur ws dvlopd y B. Gntr (984). Lt M = {,..., n}. A M is ltilly smllr thn B M, if B A if th smllst

More information

EE1000 Project 4 Digital Volt Meter

EE1000 Project 4 Digital Volt Meter Ovrviw EE1000 Projt 4 Diitl Volt Mtr In this projt, w mk vi tht n msur volts in th rn o 0 to 4 Volts with on iit o ury. Th input is n nlo volt n th output is sinl 7-smnt iit tht tlls us wht tht input s

More information

Week 3: Connected Subgraphs

Week 3: Connected Subgraphs Wk 3: Connctd Subgraphs Sptmbr 19, 2016 1 Connctd Graphs Path, Distanc: A path from a vrtx x to a vrtx y in a graph G is rfrrd to an xy-path. Lt X, Y V (G). An (X, Y )-path is an xy-path with x X and y

More information

Linked-List Implementation. Linked-lists for two sets. Multiple Operations. UNION Implementation. An Application of Disjoint-Set 1/9/2014

Linked-List Implementation. Linked-lists for two sets. Multiple Operations. UNION Implementation. An Application of Disjoint-Set 1/9/2014 Disjoint Sts Data Strutur (Chap. 21) A disjoint-st is a olltion ={S 1, S 2,, S k } o distint dynami sts. Eah st is idntiid by a mmbr o th st, alld rprsntativ. Disjoint st oprations: MAKE-SET(x): rat a

More information

Walk Like a Mathematician Learning Task:

Walk Like a Mathematician Learning Task: Gori Dprtmnt of Euction Wlk Lik Mthmticin Lrnin Tsk: Mtrics llow us to prform mny usful mthmticl tsks which orinrily rquir lr numbr of computtions. Som typs of problms which cn b on fficintly with mtrics

More information

N=4 L=4. Our first non-linear data structure! A graph G consists of two sets G = {V, E} A set of V vertices, or nodes f

N=4 L=4. Our first non-linear data structure! A graph G consists of two sets G = {V, E} A set of V vertices, or nodes f lulu jwtt pnlton sin towr ounrs hpl lpp lu Our irst non-linr t strutur! rph G onsists o two sts G = {V, E} st o V vrtis, or nos st o E s, rltionships twn nos surph G onsists o sust o th vrtis n s o G jnt

More information

Spanning Trees. BFS, DFS spanning tree Minimum spanning tree. March 28, 2018 Cinda Heeren / Geoffrey Tien 1

Spanning Trees. BFS, DFS spanning tree Minimum spanning tree. March 28, 2018 Cinda Heeren / Geoffrey Tien 1 Spnnn Trs BFS, DFS spnnn tr Mnmum spnnn tr Mr 28, 2018 Cn Hrn / Gory Tn 1 Dpt-rst sr Vsts vrts lon snl pt s r s t n o, n tn ktrks to t rst junton n rsums own notr pt Mr 28, 2018 Cn Hrn / Gory Tn 2 Dpt-rst

More information

Examples and applications on SSSP and MST

Examples and applications on SSSP and MST Exampls an applications on SSSP an MST Dan (Doris) H & Junhao Gan ITEE Univrsity of Qunslan COMP3506/7505, Uni of Qunslan Exampls an applications on SSSP an MST Dijkstra s Algorithm Th algorithm solvs

More information