moe asal
moe asal

Reputation: 582

What traversal is more probable to keep tree balanced

I am trying to simulate Conway's game of life. I am representing the 'Live cells' as a coordinate vector (x, y). The initial live cells are inserted into a kd tree (k=2) such that it is perfectly balanced. If a node doesn't exist in the tree, it is assumed to be dead.

The simulation is an array of trees with generation i at trees[i]. When transitioning from tree[i-1] to tree[i], I traverse tree[i-1] and check each node and its neighbors whether they're alive or not. If a node is alive, it gets inserted into tree[i].

What is the best way to traverse the tree such that if we start with tree[0] being perfectly balanced, we have the highest probability that the upcoming generations will be 'most balanced'?

Upvotes: 1

Views: 52

Answers (0)

Related Questions