Hii…
I am doing this graph problem from hackerearth…
Here the main logic is we have to calculate the maximum weight of edge between two node… and if that maximum value is greater than the query weight then for this query the answer will be yes…
But how to calculate the path of every node pair…
How can we do this using DFS.
Please see this question.
Thanks.
Not able to solve
Although it’s also tough for me, but if you say so i can suggest you with an approach that is
if you know about Dijkstra’s algorithm it’s for MST. Just change the conditions and try for maximum path. and then of course remaining if else condition you know. So if it helps you do let me know or if not then also let me know i would mark this doubt as mentor attention required if it helps.
Actually… I don’t know about dijkstra’s algorithm right now…
I have read about Graph, BFS and DFS and start solving problem using TAG in Hackerearth.
I will try this after reading DIJkastra’s … if any algorithm related to BFS and DFS works,
Please let me Know,…
Thanks
why we use bfs and dfs is to traverse on graph right? Though as you are saying that’s it is a weighted graph. So we use different algorithms like prims, dijkstra bellman and 2-3 more depending upon on what question it is. If i would find any solution using bfs or dfs i would surely send it to you.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.