Write a program that performs bfs on each of a given set


Problem: BFS to Fnd Distances

Write a program that performs BFS on each of a given set of digraphs starting at node 0 and prints the distance to the most distant node and reports the node with the highest index at that distance. Nodes that are not reachable from 0 have an unde?ned distance and should be ignored.

Input format: described below under the heading, "Digraph input format"

Output format: For each input digraph, print out a line with the distance to the most distant node, then a space, then the highest index of a node at that distance. Ignore nodes that are not reachable from 0.

For the example input shown below, the output would be

2 2
1 2

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a program that performs bfs on each of a given set
Reference No:- TGS03233189

Expected delivery within 24 Hours