I want to run a BFS in a square grid of size N*N. There is a single starting node. I can only move up/down/left/right (not in diagonal). There may be obstacles in the grid.
Of course I want to use a queue to store the nodes I have to visit. It will be implemented as circular array of size S (fixed size). What is the minimum size for my array? I don't want it to overflow, even in the worst possible case.
A similar problem would be : given a node in a grid, what is the maximum number of node at exactly distance K from the starting node (for any 0 < K < 2*N)?
I think it would be hard to find an exact answer to this problem so a good approximation would be enough.
See this example (the rightmost picture) :
This is not a grid but we could make grid with the same pattern (where the white represents obstacles and the black fractal are the walkable nodes). We can see that we have a lot of nodes at EXACTLY the same distance from the node in the center (actually this number doubles everytime time a path splits in two). So I would like to know how large this number could get, and if there are other configurations that yields to the same situation.
To make it very clear my question is : can this number get LARGER than 2*N where N is the size of the N*N square grid.