Question: I need help for solving Graph data structure algorithm problem, the question is as following: We have Directed acyclic Graph we have to find the

I need help for solving Graph data structure algorithm problem, the question is as following: We have Directed acyclic Graph we have to find the number of longest path. If there is any cycle in the graph we have to return a string "cycle found" otherwise we have to return the number of nodes in the longest path. Another key point here is there might be some DA graph that are not connected together.

I'm not sure if I was clear, that's why below I put some example cases. If you look at the table there is a procedure. In the first column the second line contains N names representing the names of each resource. Then on the next N lines: line i contains the name of the parent resource for the resource that has the index i.

Data limits: 1

You can help me with a code in java, Thank you!

I need help for solving Graph data structure algorithm problem, the question

If you have any other question please leave a commentis as following: We have Directed acyclic Graph we have to find

resources.in resources.out 5 4 Diesel CO2 Plastics Bottles Microplastics Petrol Diesel Petrol Plastics Bottles Petrol Diesel Plastics CO2 Bottles Microplastics resources.in resources.out 4 Cycle detected! ABCD C A B B Base Base B D resources.in resources.out 5 4 Diesel CO2 Plastics Bottles Microplastics Petrol Diesel Petrol Plastics Bottles Petrol Diesel Plastics CO2 Bottles Microplastics resources.in resources.out 4 Cycle detected! ABCD C A B B Base Base B D

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!