HomeWork 2
Algorithms
CSE 4081/5211
Fall 2005
Points 25 (UG) /35 (Grad):
Due: 9/20/05, Tuesday
1. Algorithm tracing [Points 15]: Implement the two Topological Sort algorithms (Naïve
and Qbased). Implementations must use adjacency list as the graph data structure. Print
the identifier for a node whenever it is looked up in the algorithm. Specifically in my
algorithms:
(In Naïve Toposort)
Print each node when its indegeree is initially calculated; each node when it is checked
for its indegree in the loop for “
v
= a vertex with zero indegree;” and each node
w
before
the line “decrement indegree of
w
by 1;”
(In Qbased TopoSort)
Print each node
v
when its indegeree is calculated before line “calculate indegree(v);”
each node
v
after it is dequed in line “
v
= dequeue from the head of
Q
;” each node
w
before line “decrement
indegree
of
w
;”
Run your implementations over the following three input directed graphs.
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.
 Spring '12
 Dmitra
 Algorithms, Graph Theory, Sort

Click to edit the document details