Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Specification: Using Java programming language, do a Depth-first search of the directed graph, starting at the node with the value S (not case sensitive).

Problem Specification:

Using Java programming language, do a Depth-first search of the directed graph, starting at the node with the value S (not case sensitive). List the starting and finishing times of each Node, and the class of each Edge (tree edge(T), forward edge(F), back edge(B), cross edge(C)). Make the starting time of the source node time 1. At many points in the search, you may have to choose which node to explore next. Here are the rules to do so:

  1. If you have a choice among two or more unexplored Node to explore next, there are two cases:
  1. If the values of all Edges are all integers, choose the Edge with the lowest value. If there is a tie, choose the Edge to the Node whose name comes first in lexicographic order. (All node names are unique.)
  2. Otherwise, if the values of the Edges are not all integers (at least one general alphabetical character or non-positive integer), choose the Edge to the Node whose name comes first in lexicographic order.
  1. If you have explored as far as possible from the starting node without exploring every node of the graph, continue from the Node whose name comes first lexicographically from among all unexplored Nodes.

The sample input which must be provided through text file

~ val AAA BB C DDD E Alfa S ~ > ~ 99 fig Bravo 67 999 -42 3 x == Charlie ~ ~ 4 ~ yz 9 Delta 4e 3 22 x ~ !=2 Echo yes ~ ~ ~ d>e 33

image text in transcribed

Here is the definition of tree edge(T) and cross edge (C) are:

  1. Given a graph G = (V, E), we can use depth-first search to construct a tree on G. An edge (u, v) E is in the tree if DFS finds either vertex u or v for the first time when exploring (u, v) (All the Green edges are tree edges(T).)
  2. A cross edge is an edge from a vertex u to a vertex v such that the subtrees rooted at u and v are distinct. (It is an edge that connects two nodes such that they do not have any ancestor and a descendant relationship between them. Edge from node 5 to 4 is a cross edge(C).)

image text in transcribed

The output for this file should be: Node Alpha Bravo Charlie Delta Echo Start Time 1 2 3 4 5 End Time 10 9 8 7 6 Edge AAA-BB AAA-DDD AAA-EEE BB-AAA BB-BB BB-C BB-DDD BB-E C-BB C-DDD C-E DDD-AAA DDD-BB DDD-C DDD-E E-DDD E-E Type F F B B T F F B F B B B T B B 1 2 3 4 5 8 7 6 The output for this file should be: Node Alpha Bravo Charlie Delta Echo Start Time 1 2 3 4 5 End Time 10 9 8 7 6 Edge AAA-BB AAA-DDD AAA-EEE BB-AAA BB-BB BB-C BB-DDD BB-E C-BB C-DDD C-E DDD-AAA DDD-BB DDD-C DDD-E E-DDD E-E Type F F B B T F F B F B B B T B B 1 2 3 4 5 8 7 6

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

What is the difference between specificity and sensitivity?

Answered: 1 week ago

Question

What is your least favorite U.S. dialect? Why?

Answered: 1 week ago

Question

Write an elaborate note on marketing environment.

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

c. Will leaders rotate periodically?

Answered: 1 week ago

Question

b. Will there be one assigned leader?

Answered: 1 week ago