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!
If you have any other question please leave a comment
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 DStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started