To kp: I am sorry I don't really understand what you mean here. The answer is NO in a following case: if rectangle with corners (x1,y1) and (x2,y2) contain at least one unvisited cell. For this test case, how would your program run? 6 2 2 1 1 4 4 x x x x x E S=start, T=treasure, E=end x x x x T x x ...