16-Greedy-Algorithms

# 16-Greedy-Algorithms - Algorithms LECTURE 16 Greedy...

This preview shows pages 1–10. Sign up to view the full content.

Algorithms L16.1 Professor Ashok Subramanian L ECTURE 16 Greedy Algorithms (and Graphs) Graph representation Minimum spanning trees Optimal substructure Greedy choice Prim’s greedy MST algorithm Algorithms

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

View Full Document
Algorithms L16.2 Graphs (review) Definition. A directed graph ( digraph ) G = ( V , E ) is an ordered pair consisting of a set V of vertices (singular: vertex ), a set E V × V of edges . In an undirected graph G = ( V , E ) , the edge set E consists of unordered pairs of vertices. In either case, we have | E | = O ( V ) . Moreover, (Review CLRS, Appendix B.)
Algorithms L16.3 Adjacency-matrix representation The adjacency matrix of a graph G = ( V , E ) , where V = {1, 2, …, n } , is the matrix A [1 . . n , 1 . . n ] given by A [ i , j ] = 1 if ( i , j ) E , 0 if ( i , j ) E .

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

View Full Document
Algorithms L16.4 Adjacency-matrix representation The adjacency matrix of a graph G = ( V , E ) , where V = {1, 2, …, n } , is the matrix A [1 . . n , 1 . . n ] given by A [ i , j ] = 1 if ( i , j ) E , 0 if ( i , j ) E . 2 1 3 4 A 1 2 3 4 1 2 3 4 0 1 1 0 0 0 1 0 0 0 0 0 0 0 1 0 Θ ( V ) storage
Algorithms L16.5 Adjacency-list representation An adjacency list of a vertex v V is the list Adj [ v ] of vertices adjacent to v . 2 1 3 4 Adj [1] = {2, 3} Adj [2] = {3} Adj [3] = {} Adj [4] = {3}

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

View Full Document
Algorithms L16.6 Adjacency-list representation An adjacency list of a vertex v V is the list Adj [ v ] of vertices adjacent to v . 2 1 3 4 Adj [1] = {2, 3} Adj [2] = {3} Adj [3] = {} Adj [4] = {3} For undirected graphs, | Adj [ v ] | = degree ( v ) . For digraphs, | Adj [ v ] | = out-degree ( v ) .
Algorithms L16.7 Adjacency-list representation An adjacency list of a vertex v V is the list Adj [ v ] of vertices adjacent to v . 2 1 3 4 Adj [1] = {2, 3} Adj [2] = {3} Adj [3] = {} Adj [4] = {3} For undirected graphs, | Adj [ v ] | = degree ( v ) . For digraphs, | Adj [ v ] | = out-degree ( v ) . Handshaking Lemma: = 2 | E | for undirected

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

View Full Document
Algorithms L16.8 Minimum spanning trees Input: A connected, undirected graph G = ( V , E ) with weight function w : E R . For simplicity, assume that all edge weights are distinct. (CLRS covers the general case.)
Algorithms L16.9 Minimum spanning trees Input: A connected, undirected graph G = ( V , E ) with weight function w : E R . For simplicity, assume that all edge weights are

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 52

16-Greedy-Algorithms - Algorithms LECTURE 16 Greedy...

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

View Full Document
Ask a homework question - tutors are online