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

Size: px
Start display at page:

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

Transcription

1 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 Grph G = (V, E) irete or unirete nottion: n = V, m = E (note: m n 2 ) jeny list or jeny mtrix Grphs Grphs moel mny things physil networks (e.g. ros) ommunition networks (e.g. internet) inormtion networks (e.g. the we) soil networks (e.g. riens) epeneny networks (e.g. topis in this ourse) so mny unmentl lgorithms operte on grphs April 3, 2014 CS38 Leture 2 3 April 3, 2014 CS38 Leture 2 4 Grphs Grph terminology: n unirete grph is onnete i there is pth etween eh pir o verties tree is onnete, unirete grph with no yles; orest is olletion o isjoint trees irete grph is strongly onnete i there is pth rom x to y n rom y to x, 8 x,y2v DAG is Direte Ayli Grph Grph trversls Grph trversl lgorithm: visit some or ll o the noes in grph, leling them with useul inormtion reth-irst: useul or unirete, yiels onnetivity n shortest-pths inormtion epth-irst: useul or irete, yiels numering use or topologil sort strongly-onnete omponent eomposition April 3, 2014 CS38 Leture 2 5 April 3, 2014 CS38 Leture 2 6 1

2 Breth irst serh BFS(unirete grph G, strting vertex s) 1. or eh vertex v, v.olor = white, v.ist = 1, v.pre = nil 2. s.olor = grey, s.ist = 0, s.pre = nil 3. Q = ;; ENQUEUE(Q, s) 4. WHILE Q is not empty u = DEQUEUE(Q) 5. or eh v jent to u 6. IF v.olor = white THEN 7. v.olor = grey, v.ist = u.ist + 1, v.pre = u 8. ENQUEUE(Q, v) 9. u.olor = lk BFS exmple rom CLRS Lemm: BFS runs in time O(m + n), when G is represente y n jeny list. April 3, 2014 CS38 Leture Breth irst serh Lemm: or ll v 2 V, v.ist = istne(s, v), n shortest pth rom s to v is shortest pth rom s to v.pre ollowe y ege (v.pre,v) Proo: prtition V into levels L 0 = {s} L i = {v : 9 u 2 L i-1 suh tht (u,v) 2 E} Oserve: istne(s,v) = i, v 2 L i s Breth irst serh eges only within lyers or etween jent lyers L 0 L 1 L 2 L n Clim: t ny point in opertion o lgorithm: 1. lk/grey verties extly L 0, L 1,, L i n prt o L i+1 2. Q = (v 0, v 1, v 2, v 3,, v k ) n ll hve v.ist = level o v s eges only within lyers or etween jent lyers L 0 L 1 L 2 L n level i level i+1 hols initilly: s.olor = grey, s.ist = 0, Q = (s) April 3, 2014 CS38 Leture 2 10 s Breth irst serh L 0 L 1 L 2 L n Clim: t ny point in opertion o lgorithm: 1. lk/grey verties extly L 0, L 1,, L i n prt o L i+1 2. Q = (v 0, v 1, v 2, v 3,, v k ) n ll hve v.ist = level o v level i level i+1 eges only within lyers or etween jent lyers ) level i+1 ) level i+1 1 step: equeue v 0 ; white nrs o v 0 w/ ist = v 0.ist + 1 Depth irst serh DFS(irete grph G) 1. or eh vertex v, v.olor = white, v.pre = nil 2. time = 0 3. or eh vertex u, IF u.olor = white THEN DFS-VISIT(G, u) DFS-VISIT(irete grph G, strting vertex u) 1. time = time +1, u.isovere = time, u.olor = grey 2. or eh v jent to u, IF v.olor = white THEN 3. v.pre = u, DFS-VISIT(G, v) 4. u.olor = lk; time = time + 1; u.inishe = time Lemm: DFS runs in time O(m + n), when G is represente y n jeny list. Proo? April 3, 2014 CS38 Leture 2 11 April 3, 2014 CS38 Leture

3 Depth irst serh DFS(irete grph G) 1. or eh vertex v, v.olor = white, v.pre = nil 2. time = 0 3. or eh vertex u, IF u.olor = white THEN DFS-VISIT(G, u) DFS-VISIT(irete grph G, strting vertex u) 1. time = time +1, u.isovere = time, u.olor = grey 2. or eh v jent to u, IF v.olor = white THEN 3. v.pre = u, DFS-VISIT(G, v) 4. u.olor = lk; time = time + 1; u.inishe = time Lemm: DFS runs in time O(m + n), when G is represente y n jeny list. Proo: DFS-VISIT lle or eh vertex extly one; its j. list snne one; O(1) work April 3, 2014 CS38 Leture 2 13 Depth irst serh DFS yiels orest: the DFS orest eh vertex lele with isovery time n inishing time eges o G lssiie s tree eges k eges (point k to n nestor) orwr eges (point orwr to esennt) ross eges (ll others) April 3, 2014 CS38 Leture 2 14 DFS exmple rom CLRS DFS pplition: topologil sort Given DAG, list verties v 0, v 1,., v n so tht no eges rom v i to v j (j < i) exmple: e e April 3, 2014 CS38 Leture 2 16 DFS pplition: topologil sort Theorem: listing verties in reverse orer o DFS inishing times yiels topologil sort o DAG G (n implement in liner time; how?) Proo: lim or ll (u,v) 2 E, v.inish < u.inish when (u,v) explore, v not grey sine then G woul hve yle [k-ege] v white ) esenent o u so v inishes irst v lk ) lrey one, so v.inish is set n u.inish will e set with lter time Strongly onnete omponents sy tht x» y i there is irete pth rom x to y n rom y to x in G equivlene reltion, equivlene lsses re strongly onnete omponents o G lso, mximl strongly onnete susets SCC struture is DAG (why?) April 3, 2014 CS38 Leture 2 17 April 3, 2014 CS38 Leture

4 Strongly onnete omponents DFS tree rom v in G: ll noes rehle rom v DFS tree rom v in G T : ll noes tht n reh v v G with eges reverse Key: in sink SCC, this is extly the SCC April 3, 2014 CS38 Leture 2 19 Strongly onnete omponents v given v in sink SCC, run DFS strting there, then move to next in reverse topologil orer DFS orest woul give the SCCs Key #2: topologil orering onsistent with SCC DAG struture! (why?) April 3, 2014 CS38 Leture 2 20 Strongly onnete omponents Strongly onnete omponents SCC(irete grph G) 1. run DFS(G) 2. onstrut G T rom G 3. run DFS(G T ) ut in line 3, onsier verties in eresing orer o inishing times rom the irst DFS running time O(n + m) i G in j. list note: step 2 n e one in O(m + n) time trees in DFS orest o the seon DFS re the SCCs o G April 3, 2014 CS38 Leture 2 21 SCC(irete grph G) 1. run DFS(G) 2. onstrut G T rom G 3. run DFS(G T ) ut in line 3, onsier verties in eresing orer o inishing times rom the irst DFS Corretness (sketh): irst vertex is in sink SCC, DFS-VISIT olors lk, eetively removes next unvisite vertex is in sink ter removl n so on April 3, 2014 CS38 Leture 2 22 Summry O(m + n) time lgorithms or omputing BFS tree rom v in unirete G ining shortest pths rom v in unirete G omputing DFS orest in irete G omputing topologil orering o DAG ientiying the strongly onnete omponents o irete G (ll ssume G given in jeny list ormt) Heps A si t struture eyon stks n queues: hep rry o n elt/key pirs in speil orer min-hep or mx-hep opertions: INSERT(H, elt) INCREASE-KEY(H, i) EXTRACT-MAX(H) April 3, 2014 CS38 Leture 2 23 April 3, 2014 CS38 Leture

5 Heps A si t struture eyon stks n queues: hep rry o n elt/key pirs in speil orer min-hep or mx-hep opertions: time: INSERT(H, elt) O(log n) INCREASE-KEY(H, i) O(log n) EXTRACT-MAX(H) O(log n) Heps rry A represents inry tree tht is ull exept or possily lst row height = O(log n) prent(i) = i/2 let(i) = 2i right(i) = 2i+1 hep property: A[prent(i)] A[i] or ll i April 3, 2014 CS38 Leture 2 25 April 3, 2014 CS38 Leture 2 26 Heps key opertion: HEAPIFY-DOWN(H, i) Heps key opertion: HEAPIFY-UP(H, i) A[i] my violte hep property repetely swp with lrger hil running time? O(log n) or O(ht) A[i] my violte hep property repetely swp with lrger hil running time? O(log n) or O(ht) April 3, 2014 CS38 Leture 2 27 April 3, 2014 CS38 Leture 2 28 Heps How o you implement opertions: time: INSERT(H, elt) O(log n) INCREASE-KEY(H, i) O(log n) EXTRACT-MAX(H) O(log n) using HEAPIFY-UP n HEAPIFY-DOWN? BUILD-HEAP(A): re-orers rry A so tht it stisies hep property how o we o this? running time? Heps BUILD-HEAP(A): re-orers rry A so tht it stisies hep property ll HEAPIFY-DOWN(H, i) or i rom n ownto 1 running time O(n log n) more reul nlysis: O(n) April 3, 2014 CS38 Leture 2 29 April 3, 2014 CS38 Leture

6 Heps suies to show h 0 h/2 h = O(1) note: h 0 h = O(1) or < 1 oserve: (h+1)/2 h+1 = h/(2 h ) (1+1/h)/2 (1+1/h)/2 < 1 or h > 1 April 3, 2014 CS38 Leture 2 31 Hepsort Sorting n numers using hep BUILD-HEAP(A) O(n) repetely EXTRACT-MIN(H) n O(log n) totl O(n log n) Cn we o etter? O(n)? oserve tht only ever ompre vlues no eisions se on tul vlues o keys April 3, 2014 CS38 Leture 2 32 Sorting lower oun omprison-se sort: only inormtion out A use y lgorithm omes rom pirwise omprisons hepsort, mergesort, quiksort, visulize sequene o omprisons in tree: is A[i] A[j]? Greey Algorithms eh root-le pth onsistent with 1 perm. mximum pth length log(n!) = (n log n) April 3, 2014 CS38 Leture 2 33 April 3, 2014 CS38 Leture 2 34 Greey lgorithms Greey lgorithm prigm uil up solution inrementlly t eh step, mke the greey hoie Exmple: in unirete grph G = (V,E), vertex over is suset o V tht touhes every ege hr prolem: in the smllest vertex over e April 3, 2014 CS38 Leture 2 35 Dijkstr s lgorithm given irete grph G = (V,E) with non-negtive ege weights strting vertex s 2 V in shortest pths rom s to ll noes v note: unweighte se solve y BFS April 3, 2014 CS38 Leture

7 Dijkstr s lgorithm shortest pths exhiit optiml sustruture property optiml solution ontins within it optiml solutions to suprolems shortest pth rom x to y vi z ontins shortest pth rom x to z shortest pths rom s orm tree roote t s Min ie: mintin set S µ V with orret istnes nr u with smllest istne estimte April 3, 2014 CS38 Leture

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

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

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

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

Lecture 13: Graphs I: Breadth First Search

Lecture 13: Graphs I: Breadth First Search Leture 13 Grphs I: BFS 6.006 Fll 2011 Leture 13: Grphs I: Bredth First Serh Leture Overview Applitions of Grph Serh Grph Representtions Bredth-First Serh Rell: Grph G = (V, E) V = set of verties (ritrry

More information

Introduction. Example

Introduction. Example OMS0 Introution isjoint sets n minimum spnning trees In this leture we will strt by isussing t struture use for mintining isjoint subsets of some bigger set. This hs number of pplitions, inluing to mintining

More information

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

Premaster Course Algorithms 1 Chapter 6: Shortest Paths. Christian Scheideler SS 2018 Premster Course Algorithms Chpter 6: Shortest Pths Christin Scheieler SS 8 Bsic Grph Algorithms Overview: Shortest pths in DAGs Dijkstr s lgorithm Bellmn-For lgorithm Johnson s metho SS 8 Chpter 6 Shortest

More information

MITSUBISHI ELECTRIC RESEARCH LABORATORIES Cambridge, Massachusetts. Introduction to Matroids and Applications. Srikumar Ramalingam

MITSUBISHI ELECTRIC RESEARCH LABORATORIES Cambridge, Massachusetts. Introduction to Matroids and Applications. Srikumar Ramalingam Cmrige, Msshusetts Introution to Mtrois n Applitions Srikumr Rmlingm MERL mm//yy Liner Alger (,0,0) (0,,0) Liner inepenene in vetors: v, v2,..., For ll non-trivil we hve s v s v n s, s2,..., s n 2v2...

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

COMP108 Algorithmic Foundations

COMP108 Algorithmic Foundations Grph Theory Prudene Wong http://www.s.liv..uk/~pwong/tehing/omp108/201617 How to Mesure 4L? 3L 5L 3L ontiner & 5L ontiner (without mrk) infinite supply of wter You n pour wter from one ontiner to nother

More information

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms

Paradigm 5. Data Structure. Suffix trees. What is a suffix tree? Suffix tree. Simple applications. Simple applications. Algorithms Prdigm. Dt Struture Known exmples: link tble, hep, Our leture: suffix tree Will involve mortize method tht will be stressed shortly in this ourse Suffix trees Wht is suffix tree? Simple pplitions History

More information

Bayesian Networks: Directed Markov Properties (Cont d) and Markov Equivalent DAGs

Bayesian Networks: Directed Markov Properties (Cont d) and Markov Equivalent DAGs Byesin Networks: Direte Mrkov Properties (Cont ) n Mrkov Equivlent DAGs Huizhen Yu jney.yu@s.helsinki.fi Dept. Computer Siene, Univ. of Helsinki Proilisti Moels, Spring, 2010 Huizhen Yu (U.H.) Byesin Networks:

More information

Graph theory Route problems

Graph theory Route problems Bhelors thesis Grph theory Route prolems Author: Aolphe Nikwigize Dte: 986 - -5 Sujet: Mthemtis Level: First level (Bhelor) Course oe: MAE Astrt In this thesis we will review some route prolems whih re

More information

Chapter 4 Fuzzy Graph and Relation

Chapter 4 Fuzzy Graph and Relation Chpter 4 Fuzzy Grph nd Reltion Grph nd Fuzzy Grph! Grph n G = (V, E) n V : Set of verties(node or element) n E : Set of edges An edge is pir (x, y) of verties in V.! Fuzzy Grph ~ n ( ~ G = V, E) n V :

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

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff

Outline. CS38 Introduction to Algorithms. Administrative Stuff. Administrative Stuff. Motivation/Overview. Administrative Stuff Outline CS38 Introdution to Algorithms Leture 1 April 1, 2014 administrative stuff motivation and overview of the ourse stale mathings example graphs, representing graphs graph traversals (BFS, DFS) onnetivity,

More information

Adjacency. Adjacency Two vertices u and v are adjacent if there is an edge connecting them. This is sometimes written as u v.

Adjacency. Adjacency Two vertices u and v are adjacent if there is an edge connecting them. This is sometimes written as u v. Terminology Adjeny Adjeny Two verties u nd v re djent if there is n edge onneting them. This is sometimes written s u v. v v is djent to nd ut not to. 2 / 27 Neighourhood Neighourhood The open neighourhood

More information

Problem Final Exam Set 2 Solutions

Problem Final Exam Set 2 Solutions CSE 5 5 Algoritms nd nd Progrms Prolem Finl Exm Set Solutions Jontn Turner Exm - //05 0/8/0. (5 points) Suppose you re implementing grp lgoritm tt uses ep s one of its primry dt strutures. Te lgoritm does

More information

Containers: Queue and List

Containers: Queue and List Continers: Queue n List Queue A ontiner in whih insertion is one t one en (the til) n eletion is one t the other en (the he). Also lle FIFO (First-In, First-Out) Jori Cortell n Jori Petit Deprtment of

More information

Internet Routing. Reminder: Routing. CPSC Network Programming

Internet Routing. Reminder: Routing. CPSC Network Programming PS 360 - Network Progrmming Internet Routing Mihele Weigle eprtment of omputer Siene lemson University mweigle@s.lemson.eu pril, 00 http://www.s.lemson.eu/~mweigle/ourses/ps360 Reminer: Routing Internet

More information

Lecture 8: Graph-theoretic problems (again)

Lecture 8: Graph-theoretic problems (again) COMP36111: Advned Algorithms I Leture 8: Grph-theoreti prolems (gin) In Prtt-Hrtmnn Room KB2.38: emil: iprtt@s.mn..uk 2017 18 Reding for this leture: Sipser: Chpter 7. A grph is pir G = (V, E), where V

More information

Lesson 4.4. Euler Circuits and Paths. Explore This

Lesson 4.4. Euler Circuits and Paths. Explore This Lesson 4.4 Euler Ciruits nd Pths Now tht you re fmilir with some of the onepts of grphs nd the wy grphs onvey onnetions nd reltionships, it s time to egin exploring how they n e used to model mny different

More information

Lecture 12 : Topological Spaces

Lecture 12 : Topological Spaces Leture 12 : Topologil Spes 1 Topologil Spes Topology generlizes notion of distne nd loseness et. Definition 1.1. A topology on set X is olletion T of susets of X hving the following properties. 1. nd X

More information

Class Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414

Class Overview. Database Design. Database Design Process. Database Design. Introduction to Data Management CSE 414 Introution to Dt Mngement CSE 44 Unit 6: Coneptul Design E/R Digrms Integrity Constrints BCNF Introution to Dt Mngement CSE 44 E/R Digrms ( letures) CSE 44 Autumn 08 Clss Overview Dtse Design Unit : Intro

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

Convex Hull Algorithms. Convex hull: basic facts

Convex Hull Algorithms. Convex hull: basic facts CG Leture D Conve Hull Algorithms Bsi fts Algorithms: Nïve, Gift wrpping, Grhm sn, Quik hull, Divide-nd-onquer Lower ound 3D Bsi fts Algorithms: Gift wrpping, Divide nd onquer, inrementl Conve hulls in

More information

CMPUT101 Introduction to Computing - Summer 2002

CMPUT101 Introduction to Computing - Summer 2002 CMPUT Introdution to Computing - Summer 22 %XLOGLQJ&RPSXWHU&LUFXLWV Chpter 4.4 3XUSRVH We hve looked t so fr how to uild logi gtes from trnsistors. Next we will look t how to uild iruits from logi gtes,

More information

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal

CS 551 Computer Graphics. Hidden Surface Elimination. Z-Buffering. Basic idea: Hidden Surface Removal CS 55 Computer Grphis Hidden Surfe Removl Hidden Surfe Elimintion Ojet preision lgorithms: determine whih ojets re in front of others Uses the Pinter s lgorithm drw visile surfes from k (frthest) to front

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

1 Disjoint-set data structure.

1 Disjoint-set data structure. CS 124 Setion #4 Union-Fin, Greey Algorithms 2/20/17 1 Disjoint-set ata struture. 1.1 Operations Disjoint-set ata struture enale us to effiiently perform operations suh as plaing elements into sets, querying

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

Structure in solution spaces: Three lessons from Jean-Claude

Structure in solution spaces: Three lessons from Jean-Claude Struture in solution spes: Three lessons from Jen-Clue Dvi Eppstein Computer Siene Deprtment, Univ. of Cliforni, Irvine Conferene on Meningfulness n Lerning Spes: A Triute to the Work of Jen-Clue Flmgne

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

CS553 Lecture Introduction to Data-flow Analysis 1

CS553 Lecture Introduction to Data-flow Analysis 1 ! Ide Introdution to Dt-flow nlysis!lst Time! Implementing Mrk nd Sweep GC!Tody! Control flow grphs! Liveness nlysis! Register llotion CS553 Leture Introdution to Dt-flow Anlysis 1 Dt-flow Anlysis! Dt-flow

More information

Minimal Memory Abstractions

Minimal Memory Abstractions Miniml Memory Astrtions (As implemented for BioWre Corp ) Nthn Sturtevnt University of Alert GAMES Group Ferury, 7 Tlk Overview Prt I: Building Astrtions Minimizing memory requirements Performnes mesures

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

Elementary Graph Algorithms

Elementary Graph Algorithms Elementary Graph Algorithms Representations Breadth-First Search Depth-First Search Topological Sort Strongly Connected Components CS 5633 Analysis of Algorithms Chapter 22: Slide 1 Graph Representations

More information

Graph Contraction and Connectivity

Graph Contraction and Connectivity Chpter 14 Grph Contrtion n Connetivity So fr we hve mostly overe tehniques for solving problems on grphs tht were evelope in the ontext of sequentil lgorithms. Some of them re esy to prllelize while others

More information

s 1 t 4 s 2 4 t 2 a b r 2 r 8 r10 g 4

s 1 t 4 s 2 4 t 2 a b r 2 r 8 r10 g 4 k-pirs Non-Crossing Shortest Pths in Simple Polgon Evnthi Ppdopoulou Northwestern Universit, Evnston, Illinois 60208, USA Astrt. This pper presents n O(n + k) time lgorithm to ompute the set of k non-rossing

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

Outline. Motivation Background ARCH. Experiment Additional usages for Input-Depth. Regular Expression Matching DPI over Compressed HTTP

Outline. Motivation Background ARCH. Experiment Additional usages for Input-Depth. Regular Expression Matching DPI over Compressed HTTP ARCH This work ws supported y: The Europen Reserh Counil, The Isreli Centers of Reserh Exellene, The Neptune Consortium, nd Ntionl Siene Foundtion wrd CNS-119748 Outline Motivtion Bkground Regulr Expression

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

Introduction to Algebra

Introduction to Algebra INTRODUCTORY ALGEBRA Mini-Leture 1.1 Introdution to Alger Evlute lgeri expressions y sustitution. Trnslte phrses to lgeri expressions. 1. Evlute the expressions when =, =, nd = 6. ) d) 5 10. Trnslte eh

More information

Table-driven look-ahead lexical analysis

Table-driven look-ahead lexical analysis Tle-riven look-he lexil nlysis WUU YANG Computer n Informtion Siene Deprtment Ntionl Chio-Tung University, HsinChu, Tiwn, R.O.C. Astrt. Moern progrmming lnguges use regulr expressions to efine vli tokens.

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

Outline. Graphs Describing Precedence. Graphs Describing Precedence. Topological SorFng of DAGs. Graphs Describing Precedence 4/25/12. Part 10.

Outline. Graphs Describing Precedence. Graphs Describing Precedence. Topological SorFng of DAGs. Graphs Describing Precedence 4/25/12. Part 10. 4// Outlin Prt. Grphs CS Algorithms n Dt Struturs Introution Trminology Implmnting Grphs Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits Grphs Dsriing Prn Grphs Dsriing

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

Graduate Algorithms CS F-15 Graphs, BFS, & DFS

Graduate Algorithms CS F-15 Graphs, BFS, & DFS Grauate Algorithms CS67-206F-5 Graphs, BFS, & DFS Davi Galles Department o Computer Science University o San Francisco 5-0: Graphs A graph consists o: A set o noes or vertices (terms are interchangeable)

More information

Internet Routing. IP Packet Format. IP Fragmentation & Reassembly. Principles of Internet Routing. Computer Networks 9/29/2014.

Internet Routing. IP Packet Format. IP Fragmentation & Reassembly. Principles of Internet Routing. Computer Networks 9/29/2014. omputer Networks 9/29/2014 IP Pket Formt Internet Routing Ki Shen IP protool version numer heder length (words) for qulity of servie mx numer remining hops (deremented t eh router) upper lyer protool to

More information

ITEC2620 Introduction to Data Structures

ITEC2620 Introduction to Data Structures ITEC0 Introduction to Dt Structures Lecture 7 Queues, Priority Queues Queues I A queue is First-In, First-Out = FIFO uffer e.g. line-ups People enter from the ck of the line People re served (exit) from

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

Partitioning for Parallelization Using Graph Parsing

Partitioning for Parallelization Using Graph Parsing Prtitioning for Prlleliztion Using Grph Prsing C. L. MCrery Deprtment of Computer Siene n Engineering Auurn University, Al 36849 e-mil: mrery@eng.uurn.eu (205) 844-6307 List of Figures Figure 3.1 Figure

More information

Lesson6: Modeling the Web as a graph Unit5: Linear Algebra for graphs

Lesson6: Modeling the Web as a graph Unit5: Linear Algebra for graphs Lesson6: Modeling the We s grph Unit5: Liner Alger for grphs Rene Pikhrdt Introdution to We Siene Prt 2 Emerging We Properties Rene Pikhrdt Institute CC-BY-SA-3. for We Siene nd Tehnologies Modeling the

More information

Comparison-based Choices

Comparison-based Choices Comprison-se Choies John Ugner Mngement Siene & Engineering Stnfor University Joint work with: Jon Kleinerg (Cornell) Senhil Mullinthn (Hrvr) EC 17 Boston June 28, 2017 Preiting isrete hoies Clssi prolem:

More information

Computational geometry

Computational geometry Leture 23 Computtionl geometry Supplementl reding in CLRS: Chpter 33 exept 33.3 There re mny importnt prolems in whih the reltionships we wish to nlyze hve geometri struture. For exmple, omputtionl geometry

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

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

CS 241 Week 4 Tutorial Solutions

CS 241 Week 4 Tutorial Solutions CS 4 Week 4 Tutoril Solutions Writing n Assemler, Prt & Regulr Lnguges Prt Winter 8 Assemling instrutions utomtilly. slt $d, $s, $t. Solution: $d, $s, nd $t ll fit in -it signed integers sine they re 5-it

More information

CS453 INTRODUCTION TO DATAFLOW ANALYSIS

CS453 INTRODUCTION TO DATAFLOW ANALYSIS CS453 INTRODUCTION TO DATAFLOW ANALYSIS CS453 Leture Register llotion using liveness nlysis 1 Introdution to Dt-flow nlysis Lst Time Register llotion for expression trees nd lol nd prm vrs Tody Register

More information

Duality in linear interval equations

Duality in linear interval equations Aville online t http://ijim.sriu..ir Int. J. Industril Mthemtis Vol. 1, No. 1 (2009) 41-45 Dulity in liner intervl equtions M. Movhedin, S. Slhshour, S. Hji Ghsemi, S. Khezerloo, M. Khezerloo, S. M. Khorsny

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

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

Asurveyofpractical algorithms for suffix tree construction in external memory

Asurveyofpractical algorithms for suffix tree construction in external memory Asurveyofprtil lgorithms for suffix tree onstrution in externl memory M. Brsky,, U. Stege n A. Thomo University of Vitori, PO Box, STN CSC Vitori, BC, VW P, Cn SUMMAY The onstrution of suffix trees in

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

Comparing Hierarchical Data in External Memory

Comparing Hierarchical Data in External Memory Compring Hierrhil Dt in Externl Memory Surshn S. Chwthe Deprtment of Computer Siene University of Mryln College Prk, MD 090 hw@s.um.eu Astrt We present n externl-memory lgorithm for omputing minimum-ost

More information

22.3 Depth First Search

22.3 Depth First Search 22.3 Depth First Search Depth-First Search(DFS) always visits a neighbour of the most recently visited vertex with an unvisited neighbour. This means the search moves forward when possible, and only backtracks

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures an Algorithms CS-0S-9 Connecte Components Davi Galles Department o Computer Science University o San Francisco 9-0: Strongly Connecte Graph Directe Path rom every noe to every other noe

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

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

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

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string.

CS 340, Fall 2016 Sep 29th Exam 1 Note: in all questions, the special symbol ɛ (epsilon) is used to indicate the empty string. CS 340, Fll 2016 Sep 29th Exm 1 Nme: Note: in ll questions, the speil symol ɛ (epsilon) is used to indite the empty string. Question 1. [10 points] Speify regulr expression tht genertes the lnguge over

More information

Tight triangulations: a link between combinatorics and topology

Tight triangulations: a link between combinatorics and topology Tight tringultions: link between ombintoris nd topology Jonthn Spreer Melbourne, August 15, 2016 Topologil mnifolds (Geometri) Topology is study of mnifolds (surfes) up to ontinuous deformtion Complited

More information

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator.

COMMON FRACTIONS. or a / b = a b. , a is called the numerator, and b is called the denominator. COMMON FRACTIONS BASIC DEFINITIONS * A frtion is n inite ivision. or / * In the frtion is lle the numertor n is lle the enomintor. * The whole is seprte into "" equl prts n we re onsiering "" of those

More information

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Computer Science & Engineering 423/823 Design and Analysis of Algorithms Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 04 Elementary Graph Algorithms (Chapter 22) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu Introduction

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

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

Calculus Differentiation

Calculus Differentiation //007 Clulus Differentition Jeffrey Seguritn person in rowot miles from the nerest point on strit shoreline wishes to reh house 6 miles frther down the shore. The person n row t rte of mi/hr nd wlk t rte

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

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs.

Advanced Programming Handout 5. Enter Okasaki. Persistent vs. Ephemeral. Functional Queues. Simple Example. Persistent vs. Avne Progrmming Hnout 5 Purel Funtionl Dt Strutures: A Cse Stu in Funtionl Progrmming Persistent vs. Ephemerl An ephemerl t struture is one for whih onl one version is ville t time: fter n upte opertion,

More information

COSC 6374 Parallel Computation. Non-blocking Collective Operations. Edgar Gabriel Fall Overview

COSC 6374 Parallel Computation. Non-blocking Collective Operations. Edgar Gabriel Fall Overview COSC 6374 Prllel Computtion Non-loking Colletive Opertions Edgr Griel Fll 2014 Overview Impt of olletive ommunition opertions Impt of ommunition osts on Speedup Crtesin stenil ommunition All-to-ll ommunition

More information

3D convex hulls. Convex Hull in 3D. convex polyhedron. convex polyhedron. The problem: Given a set P of points in 3D, compute their convex hull

3D convex hulls. Convex Hull in 3D. convex polyhedron. convex polyhedron. The problem: Given a set P of points in 3D, compute their convex hull Convex Hull in The rolem: Given set P of oints in, omute their onvex hull onvex hulls Comuttionl Geometry [si 3250] Lur Tom Bowoin College onvex olyheron 1 2 3 olygon olyheron onvex olyheron 4 5 6 Polyheron

More information

Basic Graph Algorithms

Basic Graph Algorithms Basic Graph Algorithms 1 Representations of Graphs There are two standard ways to represent a graph G(V, E) where V is the set of vertices and E is the set of edges. adjacency list representation adjacency

More information

Hash-based Subgraph Query Processing Method for Graph-structured XML Documents

Hash-based Subgraph Query Processing Method for Graph-structured XML Documents Hsh-bse Subgrph Query Proessing Metho for Grph-struture XML Douments Hongzhi Wng Hrbin Institute of Teh. wngzh@hit.eu.n Jinzhong Li Hrbin Institute of Teh. lijzh@hit.eu.n Jizhou Luo Hrbin Institute of

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

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

Conversion of Binary Space Partitioning Trees. to Boundary Representation. Abstract. Binary Space Partitioning Trees (BSP-Trees) have been proposed

Conversion of Binary Space Partitioning Trees. to Boundary Representation. Abstract. Binary Space Partitioning Trees (BSP-Trees) have been proposed Conversion o Bry Spe Prtitiong Trees to Bounry Representtion Jo~o Com 1 n Brue Nylor 2 1 Computer Siene Deprtment, Stnor University, USA? 2 Sptil Ls, In.?? Astrt. Bry Spe Prtitiong Trees (BSP-Trees) hve

More information

Width and Bounding Box of Imprecise Points

Width and Bounding Box of Imprecise Points Width nd Bounding Box of Impreise Points Vhideh Keikh Mrten Löffler Ali Mohdes Zhed Rhmti Astrt In this pper we study the following prolem: we re given set L = {l 1,..., l n } of prllel line segments,

More information

WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS

WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS WORKSHOP 19 GLOBAL/LOCAL MODELING USING FEM FIELDS WS19-1 WS19-2 Prolem Desription This exerise is use to emonstrte how to mp isplement results from the nlysis of glol(overll) moel onto the perimeter of

More information

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems Distriuted Systems Priniples nd Prdigms Mrten vn Steen VU Amsterdm, Dept. Computer Siene steen@s.vu.nl Chpter 11: Distriuted File Systems Version: Deemer 10, 2012 2 / 14 Distriuted File Systems Distriuted

More information

An Efficient Algorithm for the Physical Mapping of Clustered Task Graphs onto Multiprocessor Architectures

An Efficient Algorithm for the Physical Mapping of Clustered Task Graphs onto Multiprocessor Architectures An Effiient Algorithm for the Physil Mpping of Clustere Tsk Grphs onto Multiproessor Arhitetures Netrios Koziris Pnyiotis Tsnks Mihel Romesis George Ppkonstntinou Ntionl Tehnil University of Athens Dept.

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

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

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

A distributed edit-compile workflow

A distributed edit-compile workflow Time Synhroniztion nd Logil Cloks Tody 1. The need for time synhroniztion 2. Wll lok time synhroniztion 3. Logil Time: Lmport Cloks COS 418: Distriuted Systems Leture 4 Kyle Jmieson 2 A distriuted edit-ompile

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

Analysis of Algorithms Prof. Karen Daniels

Analysis of Algorithms Prof. Karen Daniels UMass Lowell omputer Science 91.404 nalysis of lgorithms Prof. Karen aniels Spring, 2013 hapter 22: raph lgorithms & rief Introduction to Shortest Paths [Source: ormen et al. textbook except where noted]

More information

Using SIMD Registers and Instructions to Enable Instruction-Level Parallelism in Sorting Algorithms

Using SIMD Registers and Instructions to Enable Instruction-Level Parallelism in Sorting Algorithms Using SIMD Registers n Instrutions to Enle Instrution-Level Prllelism in Sorting Algorithms Timothy Furtk furtk@s.ulert. José Nelson Amrl mrl@s.ulert. Roert Niewiomski niewio@s.ulert. Deprtment of Computing

More information

Distributed Systems Principles and Paradigms

Distributed Systems Principles and Paradigms Distriuted Systems Priniples nd Prdigms Christoph Dorn Distriuted Systems Group, Vienn University of Tehnology.dorn@infosys.tuwien..t http://www.infosys.tuwien..t/stff/dorn Slides dpted from Mrten vn Steen,

More information

Information Retrieval and Organisation

Information Retrieval and Organisation Informtion Retrievl nd Orgnistion Suffix Trees dpted from http://www.mth.tu.c.il/~himk/seminr02/suffixtrees.ppt Dell Zhng Birkeck, University of London Trie A tree representing set of strings { } eef d

More information

String comparison by transposition networks

String comparison by transposition networks String omprison y trnsposition networks Alexnder Tiskin (Joint work with Peter Krushe) Deprtment of Computer Siene University of Wrwik http://www.ds.wrwik..uk/~tiskin (inludes n extended version of this

More information