02 - Algorithms Greedy Algorithms Greedy Algorithms Design and Analysis of Algorithms Andrei Bulatov Algorithms Greedy Algorithms 2-2-2 Greed is

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Algorithms – Greedy Algorithms Greedy Algorithms Design and Analysis of Algorithms Andrei Bulatov
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
“Greed … is good. Greed is right. Greed works.” “Wall Street” Algorithms – Greedy Algorithms 2-2 -2
Background image of page 2
Algorithms – Greedy Algorithms 2-3 Graph Reminder Vertices and edges Nodes and arcs Representation of graphs: -- adjacency matrix -- adjacency lists Degrees of vertices, indegree, outdegree; regular graphs Handshaking Lemma Walks, paths, and cycles; lengths Connectivity, connected components Bipartite graphs; characterization of bipartite graphs Euler and Hamilton graphs Trees, root, leaves, parent and child, descendant and ancestor Acyclic digraphs
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Algorithms – Greedy Algorithms 2-4 Graph Traversing: BFS Breadth First Search(s) Input : a graph G=(V,E) and s V Output : the connected component containing s set Discov[s]:=true and Discov[v]:=false for v s set L[0] to consist of the single element s; i:=0 while L[i] is not empty do set L[i+1] to be an empty list for u L[i] do for each (u,v) E do if Discov[v]=false then set Discov[v]:=true; add v to L[i+1] endfor endfor set i:=i+1 endwhile
Background image of page 4
Algorithms – Greedy Algorithms 2-5 BFS Tree s t u w v x s t u w v x L[0] L[1] L[2] L[3]
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/11/2009 for the course CS 405/705 taught by Professor Bulatov during the Fall '09 term at Simon Fraser.

Page1 / 17

02 - Algorithms Greedy Algorithms Greedy Algorithms Design and Analysis of Algorithms Andrei Bulatov Algorithms Greedy Algorithms 2-2-2 Greed is

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online