Combinatorial Search and Heuristic Methods Flashcards
1
Q
What is backtracking?
A
Backtracking is a systematic way to iterate through all the possible configurations
of a search space.
2
Q
Typically, when would you use backtracking?
A
When there are multiple solutions to a problem and you want to return multiple solutions
3
Q
Write out the common back tacking algorithm
A
bool finished = FALSE; /* found all solutions yet? /
backtrack(int a[], int k, data input)
{
int c[MAXCANDIDATES]; / candidates for next position /
int ncandidates; / next position candidate count /
int i; / counter */
if (is_a_solution(a,k,input))
process_solution(a,k,input);
else {
k = k+1;
construct_candidates(a,k,input,c,&ncandidates);
for (i=0; i