+ 1

How to efficiently create and traverse an infinite 2D grid (Java)

My assignment is this: - At an unmarked grid location, turn left (counter-clockwise), mark the location, and move forward. - At a marked grid location, turn right (clockwise), unmark the location, and move forward. - there is a cap of, for example, 20000 steps of the algorithm. How can I make the grid grow to accommodate for the increasing steps? I am just wondering: - How can I make a grid scale infinitely in all directions - What kind of data structure should I use for optimal efficiency (ArrayList? )

14th Dec 2021, 12:03 AM
Eric Wang
Eric Wang - avatar
1 Odpowiedź