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.

determ<strong>in</strong>e if it is constructed correctly? What is the runn<strong>in</strong>g time of this<br />

algorithm?<br />

Creativity<br />

C-13.1<br />

Say that an n-vertex directed acyclic graph is compact if there is some way<br />

of number<strong>in</strong>g the vertices of with the <strong>in</strong>tegers from 0 to n − 1 such that<br />

conta<strong>in</strong>s the edge (i, j) if <strong>and</strong> only if i < j, for all i, j <strong>in</strong> [0, n − 1]. Give an O(n 2 )-<br />

time algorithm for detect<strong>in</strong>g if is compact.<br />

C-13.2<br />

Justify Proposition 13.11.<br />

C-13.3<br />

Describe, <strong>in</strong> pseudo-code, an O(n + m)-time algorithm for comput<strong>in</strong>g all the<br />

connected components of an undirected graph G with n vertices <strong>and</strong> m edges.<br />

C-13.4<br />

Let T be the spann<strong>in</strong>g tree rooted at the start vertex produced by the depth-first<br />

search of a connected, undirected graph G. Argue why every edge of G not <strong>in</strong> T<br />

goes from a vertex <strong>in</strong> T to one of its ancestors, that is, it is a back edge.<br />

C-13.5<br />

Suppose we wish to represent an n-vertex graph G us<strong>in</strong>g the edge list structure,<br />

assum<strong>in</strong>g that we identify the vertices with the <strong>in</strong>tegers <strong>in</strong> the set {0,1,..., n − 1}.<br />

Describe how to implement the collection E to support O(log n)-time<br />

performance for the areAdjacent method. How are you implement<strong>in</strong>g the<br />

method <strong>in</strong> this case?<br />

C-13.6<br />

Tamar<strong>in</strong>do University <strong>and</strong> many other schools worldwide are do<strong>in</strong>g a jo<strong>in</strong>t<br />

project on multimedia. A computer network is built to connect these schools<br />

us<strong>in</strong>g communication l<strong>in</strong>ks that form a free tree. The schools decide to <strong>in</strong>stall a<br />

file server at one of the schools to share data among all the schools. S<strong>in</strong>ce the<br />

transmission time on a l<strong>in</strong>k is dom<strong>in</strong>ated by the l<strong>in</strong>k setup <strong>and</strong> synchronization,<br />

the cost of a data transfer is proportional to the number of l<strong>in</strong>ks used. Hence, it<br />

is desirable to choose a "central" location for the file server. Given a free tree T<br />

<strong>and</strong> a node v of T, the eccentricity of v is the length of a longest path from v to<br />

873

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

Saved successfully!

Ooh no, something went wrong!