سؤال

Like in title. What is the optimal way to keep nodes in memory for Kruskal's algorithm, and why?

هل كانت مفيدة؟

المحلول

Kruskal algorithm is basically dong exactly what the Disjoint set forest structure is meant to do. This structure starts with all nodes being in separate components and then supports operations of the kind

Join nodes A and B

and

Are Nodes A and B in the same cover tree already?

That is exactly why I would tell this is the most suitable representation for the nodes.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top