Using the stack to implement the recursive maze problem