Javali
Javali

Reputation: 1

I am trying to fill a graph, what is the most optimized way to store the explored nodes?

I'm using an ArrayList and then using contains to see if the new node is already explored. Is there a better way? Time and space wise?

Upvotes: 0

Views: 52

Answers (2)

Javali
Javali

Reputation: 1

I ended up using a boolean [][][][] explored. It was much faster.

Upvotes: 0

Sahan Jayasumana
Sahan Jayasumana

Reputation: 11

HashSet, alternatively if you are worried about duplicate keys a HashMap where the key is the Nodes HAshValue and the Value is the node

Upvotes: 1

Related Questions