My doubt is that how can I be sure that the graph is a tree and there would be no 2 diff paths connecting the 2 nodes.
Coz in that case the shortest path thing would be not valid… I would have to calculate shortest path from something like dijkstra or floyd algo’s
Doubt regarding the shortest path
It clearly says in there are N cities(nodes) and N-1 roads(edges).
Now since its mentioned that all cities are connected, the only possible way is to construct a tree.
There can be no loops, check the definition of a tree.
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.