วันศุกร์ที่ 20 กุมภาพันธ์ พ.ศ. 2569

Backtracking

Backtracking is a class of algorithms for finding solutions to some computational problems, notably constraint satisfaction or enumeration problems, that incrementally builds candidates to the solutions, and abandons a candidate ("backtracks") as soon as it determines that the candidate cannot possibly be completed to a valid solution.

Example is Maze Solving (เขาวงกต): Moving through a maze and turning back when you hit a wall to try the other fork in the road.

Backtracking is implemented by means of recursion.