Give an algorithm that correctly solves the DCDP. The running time of your algorithm should be
O(m+n) for a graph with n nodes and m edges.
A few notes:
1. Assume that the graph G is represented as an adjacency list. So the vertices are stored in
an array, and each vertex v contains references to its inlist (a list of all vertices w such
that (w,v) is an edge of G) and its outlist (a list of all vertices w such that (v, w) is an
edge of G),
2. Your solution will be graded on correctness, efficiency, and clarity. This means you will lose
points if:
• Your algorithm is incorrect.
• Your algorithm does not run in O(m+n) time.
• We cannot understand your answer after expending a reasonable amount of effort.
3. As a reminder, I recommended in class that algorithms be described using both an English
description and pseudocode. An appropriate picture or two may also enhance the clarity of
the description.