I have generated a minimum spanning tree using Kruskal's algorithm and I wanted to know how to store paths
This is my minimum spanning tree
Loc1 | Loc2 | Distance
02 | 10 | 2.00 Km
05 | 07 | 5.39 Km
02 | 09 | 5.83 Km
04 | 05 | 5.83 Km
06 | 08 | 5.83 Km
03 | 09 | 7.07 Km
01 | 04 | 11.18 Km
07 | 09 | 11.18 Km
07 | 08 | 15.81 Km
Total Weight = 70.12 Km
----------------------------------------------------
It depends on how much extra space you have. Assume you need to be space-efficient:
Complexity: O(hlogn) where h is the height of the tree and n is the number of elements in the tree (I am assuming lookup time for each node in logn).