MAIN ALGORITHM for BFS is given below. It takes a very long time when the endRow and endColumn are far from startRow and startColumn to find a path between the startPoint and endPoint in 10x10 grid. Any logical explanation on how to reduce run-time?
nums = Queue.Queue()
nums.put("")
add = ""
maze = createMaze()
maze[endRow][endColumn] = "O"
while not findEnd(maze, add):
add = nums.get()
#print(add)
for j in ["L", "R", "U", "D"]:
put = add + j
if valid(maze, put):
nums.put(put)