0
要啓動反向跟蹤算法,可以爲i = 0調用以下僞代碼; X [1..0]表示空元組。瞭解僞代碼用於反向跟蹤算法
ALGORITHM Backtrack(X[1..i])
//Gives a template of a generic backtracking algorithm
//Input: X[1..i] specifies first i promising components of a solution.
//Output: Alll the tuples representing the problem's solutions
If X[1..i] is a solution write X[1..i]
else
for each element x belongs to Si+1 consistent with X[1..i] and constraints do
X[i+1] <- x
Backtrack(X[1..i+1])
我很難理解上面的邏輯。我試圖用步驟來解決4皇后問題,但不是。請用你的幫助理解以上邏輯與4皇后問題的步驟。
謝謝!