Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A directed graph G is shown in the figure below. Assume that the adjacency lists are in alphabetical order. Apply depth - first search (

A directed graph G is shown in the figure below.
Assume that the adjacency lists are in alphabetical order. Apply depth-first search (DFS) on graph G. In the main loop of DFS, check the vertices in alphabetical order.
Answer the following questions (after the DFS is completed):
(a) What is the value of B.f?
(b) What is the value of C.f?
(c) What is the value of D.f?
(d) What is the value of H.d?
(e) What is the value of I.d?
(f) What is the value of J.d?
(g) What is the value of C.pi?
(h) What is the value of D.pi?
(i) What is the value of F.pi?
Preliminaries
We start from a source vertex, s.
Discover vertices in the graph
Three possible color values of a vertex
white, not discovered yet
gray, discovered but not explored
black, discovered and explored
Initially, all vertices are white
The source vertex is discovered first
Predecessor/Parent
While exploring (gray) node u, we check the adjacency list u.Adj
If v on u.Adj is white, we say v is discovered by u. We also say u is the parent or predecessor of v. This is denoted by v.pi=u
DFS(G)
1 for each vertex u E G.V{
2 u.color = WHITE;
3 u.pi = NIL;
4}
5 time =0;
6 for each vertex U E G.V{
7 if (u.color == WHITE){
8 DFS-Visit(G, u);
9};
10}
DFS-Visit(G, u)
1 time = time +1;
2 u.d = time;
3 u.color = GRAY;
4 for each vertex v E G.Adj[u]
5 if (v.color == WHITE){
6 v.pi = u
7 DFS-Visit(G, v)
8}
9 time = time +1;
10 u.f = time;
11 u.color = BLACK;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions