19
What is an algorithm Backtracking ?
- What are its characteristics ?
- What are its advantages and disadvantages ?
19
What is an algorithm Backtracking ?
9
Backtracking is a generic algorithm that searches, by brute force, possible solutions to computational problems (typically problems of satisfaction with restrictions).
Algorithm Example
bool acabou = FALSE;
backtrack(int a[], int k, int n) {
int c[MAXCANDIDATOS]; /* Candidatos para a próxima posição */
int ncandidatos; /* Número de candidatos para a próxima posição */
int i; /* Contador */
if (e_uma_solucao(a, k, n)) {
processar_solucao(a, k, n);
} else {
k = k + 1;
construir_candidatos(a, k, n, c, &ncandidatos);
for (i=0; i<ncandidatos; i++) {
a[k] = c[i];
backtrack(a, k, n);
if (acabou) return;
}
}
}
Basic Characteristics:
Positives:
Negative Points:
Where applicable:
Backtracking is applicable in the solution of several known problems, among which can be highlighted:
OBS: The combinatorial explosion should be kept in mind.
Source: Backtracking
Apparently you removed the figure and the example of Wikipedia, it would be important to give the proper credit. Also, the example is more a snippet than a demonstration of the algorithm, because it’s not even pseudocode. What is the language?
Browser other questions tagged algorithm computer-science
You are not signed in. Login or sign up in order to post.
I did not know, I found this here in the Wikipedia https://pt.wikipedia.org/wiki/Backtracking and I found it super fucking awesome.
– Marconi
@Marconi elaborates a constructive response and post here !
– Ricardo
I’ll leave this more experienced pros,rs. I’ve already scored as a favorite to see when the answer comes out.
– Marconi