23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

An Euler tour of a directed graph<br />

traverses each edge of<br />

always exists if<br />

vertex <strong>in</strong><br />

such a digraph .<br />

C-13.12<br />

with n vertices <strong>and</strong> m edges is a cycle that<br />

exactly once accord<strong>in</strong>g to its direction. Such a tour<br />

is connected <strong>and</strong> the <strong>in</strong>-degree equals the out-degree of each<br />

. Describe an O(n + m)-time algorithm for f<strong>in</strong>d<strong>in</strong>g an Euler tour of<br />

An <strong>in</strong>dependent set of an undirected graph G = (V,E) is a subset I of V such that<br />

no two vertices <strong>in</strong> I are adjacent. That is, if u <strong>and</strong> v are <strong>in</strong> I, then (u,v) is not <strong>in</strong><br />

E. A maximal <strong>in</strong>dependent set M is an <strong>in</strong>dependent set such that, if we were to<br />

add any additional vertex to M, then it would not be <strong>in</strong>dependent any more.<br />

Every graph has a maximal <strong>in</strong>dependent set. (Can you see this? This question is<br />

not part of the exercise, but it is worth th<strong>in</strong>k<strong>in</strong>g about.) Give an efficient<br />

algorithm that computes a maximal <strong>in</strong>dependent set for a graph G. What is this<br />

method's runn<strong>in</strong>g time?<br />

C-13.13<br />

Let G be an undirected graph G with n vertices <strong>and</strong> m edges. Describe an O(n +<br />

m)-time algorithm for travers<strong>in</strong>g each edge of G exactly once <strong>in</strong> each direction.<br />

C-13.14<br />

Justify Proposition 13.14.<br />

C-13.15<br />

Give an example of an n-vertex simple graph G that causes Dijkstra's algorithm<br />

to run <strong>in</strong> (n 2 log n) time when its implemented with a heap.<br />

C-13.16<br />

Give an example of a weighted directed graph with negative-weight edges,<br />

but no negative-weight cycle, such that Dijkstra's algorithm <strong>in</strong>correctly<br />

computes the shortest-path distances from some start vertex v.<br />

C-13.17<br />

Consider the follow<strong>in</strong>g greedy strategy for f<strong>in</strong>d<strong>in</strong>g a shortest path from vertex<br />

start to vertex goal <strong>in</strong> a given connected graph.<br />

1:<br />

Initialize path to start.<br />

875

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!