Question: When I say Given ( di ) graph G as input , I mean we are given the adja - cency lists for the (
When I say Given digraph G as input I mean we are given the adja
cency lists for the digraph ie Adjv for every vertex v in the digraph
Recall that vertices are n So you may use for each vertex v in
G or for v to n whichever is appropriate when you want to process
each vertex.
Keep in mind that a complexity of On is not as good as Om n
If you are going to compute any extra information, clearly state what
you are doing.
You must use the notation and style of pseudocode as in the book or in
the notes for the class
pts Recall that when we do a DFS on a digraph, we can encounter
two types of cross edges: one is between vertices in the same tree in the
DFSforest, and the other is between vertices in different trees in the
DFSforest. Present a complete Om n time algorithm that, given
a digraph G performs DFS and during the search detects all the
cross edges of each type and outputs them in the following format:
is a cross edge within a tree
is a cross edge across trees
Hint: You should already know, from class, how to detect a cross edge.
How do you tell one type from another? Here is one way: simply keep
track for each vertex w the root of the DFStree it belongs to; record
that information in the array entry rootw and use itwrite pesucode to create an algorithm that determines all the cross edges in a dfs forest
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
