Do what? For maze, standard algorithm is to use stack. That's PUSH and POP operation. POP a location, PUSH new ones.