I have a symmetric 2d array “myMSTdata[][]” of points that represents a minimum spanning tree MST with values 0 if there is no edge or real value that represent the weights on the edges and now I need to partition this tree into two subtrees (part1,part2) where the the cutting criteria is the edge with the maximum weight. Then repeatedly keep partitioning the larger size subtree (which means the subtree with the greater number of nodes) till the remaining number of nodes in the larger size subtree is K.
I have a symmetric 2d array myMSTdata[][] of points that represents a minimum spanning
Share
Would suggest the use of Adjacency list for this kind of operations, since
May I know the complexity you are looking at ?
If you are happy with any complexity I would suggest repeated DFS, since you are working with a tree, a repeated DFS will cover all edge & vertices. The runtime will be about O(n^2) in the worst case.