**
CSE 4081/5081 Analysis of Algorithms
Fall 1997 -- Proejct 1
Assigned September 8, 1997 -- Due October 6, 1997
**

A simple search algorithm can be used to solve an instance of reachability
works as follows: Throughout the algorithm a set of vertices, denoted by
*S* is maintained. Initially, . Each node can be either
*marked* or *unmarked*. That node *i* is marked means that *i* has
been in *S* at some point in the past or is currently in *S*.
Initially, only *i* is marked. At each iteration of the algorithm, choose a
node and remove it from *S*. Process each edge out of
*i*. If *j* is unmarked, mark it and add it to *S*. Continue this process
until *S* becomes empty. At this point, answer ``yes'' if *n* is marked
and ``no'' otherwise.

The informal statements above can be written in pseudo-code.

int NO = 0; int YES = 1; int reachability(graph G, node a, node b) { for each node i of G set i to unmarked; set S; empty(S); mark(a); insert(a, S); while (notempty(S)) { remove node i from S; for each edge (i, j) in G { if j is unmarked { mark(j); insert(j, S); } } } if (marked(b) return YES; else return NO; }

Your assignment is to write a report that clarifies many of the important details left out of the above discussion. In particular,

- How is the graph represented as input to the algorithm?
- How is the set
*S*represented and how are elements chosen among all the elements of*S*? - How does one know that the algorithm will terminate?
- Given that the algorithm terminates how does one argue that is correctly answers the reachability problem?
- How would you measure the time complexity of the algorithm and What is the time complexity as a function of the number of nodes in the graph?
- Does the time complexity depend on the data structures used to represent the graph or the set of marked nodes?

Lastly, you are to write a program that implements the algorithm and execute it on several graph instances. You should be able to empirically show that the time needed to run the algorithm matches the time complexity function found above. It should not be necessary to insert explicit timing commands into the code itself, a profiler can be used to determine the time and/or number of steps needed to execute the code on a particular instance.

**
Your report should include a well-written discussion of the reachability
problem (perhaps you can include real-world applications), answers to the
above questions, a listing of your program and timing results from
several runs of you program. The report is due October 6, 1997.
**

Florida Tech Computer Science

William D. Shoaff

Comments to author:`wds@cs.fit.edu`

All contents copyright ©, William D. Shoaff

Revised: Mon Sep 8 13:17:30 EST 1997