Search and backtracking

In fact, it can be understood, a fool Maze, each wall will be able to find a final touch path.

Framework (1)

int search(int k)

{

for (i = 1; i <= Sanfu 种数; i ++)

if (the condition)

{

Save Results

(The destination) if the output Solution

else search(k+1);

Recovery: The results saved state before backtracking step {}

}

}

The frame (2)

int search(int k)

{

if (the destination) output solution;

else

for (i = 1; i <= Sanfu 种数; i ++)

if (the condition)

{

Save results;

search(k+1);

Recovery: The results saved state before backtracking step {}

}

}

Guess you like

Origin www.cnblogs.com/lizhengde/p/12361675.html