Recursion 응용 - 미로찾기
Decision Problem
boolean findPath(x, y)
// 1) 현재 위치가 출구거나
if (x, y) is the exit
return true;
// 2)
else
// x,y에 이웃한 인접한 셀(최대 4개) 각각에 대해
for each neighbouring cell (x', y') of (x,y) do
// wall이 아닌 길이라면
if (x', y') is on the pathway
// 이 길에 대해서 다시 findPath
if findPath(x', y')
return true
return false;해결책은?
코드 짜보자
Last updated
Was this helpful?