第6章 回溯法.ppt

第6章回溯法重点讲义

6.3 回溯法的一般框架 二、回溯法的一般框架 1.递归形式 Algorithm BACKTRACKREC Input:Explicit or implicit description of the sets X1, X2,…, Xn. Output:A solution vertice v=( x[1], x[2],…, x[i]),0≤i≤n. 1. v←{ } 2. flag←false 3. advance(1) 4. if flag then output? v 5. else output? “no solution” Procedure advance(k) ?? 1. for each x∈Xk ?? 2.???? x[k]←x; append x[k] to v ?? 3.????????? if v is a final solution then set flag←true and exit ?? 4.????????? else if c is partial then advance(k+1) ?? 5. end for 6.3 回溯法的一般框架 二、回溯法的一般框架 2.迭代形式 Algorithm BACKTRACKITER Input: Explicit or implicit description of th

文档评论(0)

1亿VIP精品文档

相关文档