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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

P-13.9<br />

Design an experimental comparison of repeated DFS traversals versus the<br />

Floyd-Warshall algorithm for comput<strong>in</strong>g the transitive closure of a digraph.<br />

P-13.10<br />

Implement Kruskal's algorithm assum<strong>in</strong>g that the edge weights are <strong>in</strong>tegers.<br />

P-13.11<br />

Implement the Prim-Jarník algorithm assum<strong>in</strong>g that the edge weights are<br />

<strong>in</strong>tegers.<br />

P-13.12<br />

Perform an experimental comparison of two of the m<strong>in</strong>imum spann<strong>in</strong>g tree<br />

algorithms discussed <strong>in</strong> this chapter (Kruskal <strong>and</strong> Prim-Jarník). Develop an<br />

extensive set of experiments to test the runn<strong>in</strong>g times of these algorithms us<strong>in</strong>g<br />

r<strong>and</strong>omly generated graphs.<br />

P-13.13<br />

One way to construct a maze starts with an n×n grid such that each grid cell is<br />

bounded by four unit-length walls. We then remove two boundary unit-length<br />

walls, to represent the start <strong>and</strong> f<strong>in</strong>ish. For each rema<strong>in</strong><strong>in</strong>g unit-length wall not<br />

on the boundary, we assign a r<strong>and</strong>om value <strong>and</strong> create a graph G, called the<br />

dual, such that each grid cell is a vertex <strong>in</strong> G <strong>and</strong> there is an edge jo<strong>in</strong><strong>in</strong>g the<br />

vertices for two cells if <strong>and</strong> only if the cells share a common wall. The weight of<br />

each edge is the weight of the correspond<strong>in</strong>g wall. We construct the maze by<br />

f<strong>in</strong>d<strong>in</strong>g a m<strong>in</strong>imum spann<strong>in</strong>g tree T for G <strong>and</strong> remov<strong>in</strong>g all the walls<br />

correspond<strong>in</strong>g to edges <strong>in</strong> T. Write a program that uses this algorithm to<br />

generate mazes <strong>and</strong> then solves them. M<strong>in</strong>imally, your program should draw the<br />

maze <strong>and</strong>, ideally, it should visualize the solution as well.<br />

P-13.14<br />

Write a program that builds the rout<strong>in</strong>g tables for the nodes <strong>in</strong> a computer<br />

network, based on shortest-path rout<strong>in</strong>g, where path distance is measured by<br />

hop count, that is, the number of edges <strong>in</strong> a path. The <strong>in</strong>put for this problem is<br />

the connectivity <strong>in</strong>formation for all the nodes <strong>in</strong> the network, as <strong>in</strong> the follow<strong>in</strong>g<br />

example:<br />

241.12.31.14: 241.12.31.15 241.12.31.18 241.12.31.19<br />

which <strong>in</strong>dicates three network nodes that are connected to 241.12.31.14, that is,<br />

three nodes that are one hop away. The rout<strong>in</strong>g table for the node at address A is<br />

a set of pairs (B,C), which <strong>in</strong>dicates that, to route a message from A to B, the<br />

881

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

Saved successfully!

Ooh no, something went wrong!