正在加载图片...
清华大学出版社 TSINGHUA UNIVERSITY PRESS 递归回溯 回溯法对解空间作深度优先搜索,因此,在一般情况下 用递归方法实现回溯法。 void backtrack(int if(tsn output(x) else for(int i=f(n, t); i <=g(n, t); i ++)i t]=h( if(constraint(t)&&bound(t)) backtrack(t+1)6 递归回溯 回溯法对解空间作深度优先搜索,因此,在一般情况下 用递归方法实现回溯法。 void backtrack (int t) { if (t>n) output(x); else for (int i=f(n,t);i<=g(n,t);i++) { x[t]=h(i); if (constraint(t)&&bound(t)) backtrack(t+1); } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有