Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

CSC112 Spring 2016 Examples

2370 views
1
#include "backtrack.h"
2
3
//the simple backtracking algorithm
4
bool backtrack(MoveState *c)
5
{
6
if(c->reject()) return false;
7
if(c->accept()) return true;
8
9
MoveState *c2;
10
while(c2=c->next()) {
11
if(backtrack(c2)) {
12
return true;
13
}
14
delete c2; //not that one!
15
}
16
17
return false;
18
}
19
20