EgyHakar
EgyHakar

Reputation: 11

Given x nodes and certain connections, how do you find the irrelevant connections?

Suppose you are trying to connect x nodes. There are already a number of connections >= x.

Each connection is a sub ArrayList within 1 of 2 ArrayLists (a and b).

How do you remove the unnecessary connections, such that a and b have the closest amount of connections to each other, and all nodes are connected?

I know that the min number of connections is x-1. I have tried using prim's, but, I'm not exactly sure how to apply it here.

Here are the 2 arraylists:

ArrayList<ArrayList<Integer>> list1 = new ArrayList<ArrayList<Integer>>();
ArrayList<ArrayList<Integer>> list2 = new ArrayList<ArrayList<Integer>>();

I've given them certain values from input

Upvotes: 1

Views: 37

Answers (0)

Related Questions