I am not very good at algorithms and i will have a test about backtracking these days !
I don't know where i can find the code of backtracking in C and a good explanation about it.
Thanks for attention!
I am not very good at algorithms and i will have a test about backtracking these days !
I don't know where i can find the code of backtracking in C and a good explanation about it.
Thanks for attention!
Did you check wikipedia ?
I can´t find a generic C code for this problem... :|
>I can´t find a generic C code for this problem...
That's because there isn't one. Backtracking is a solution strategy, not an algorithm. You can implement it dozens of ways depending on what needs to be backtracked and how. Maybe instead of trying to find something concrete, you should post the problem you're trying to solve and we can offer advice on how to implement the solution.
As Narue told you, backtraking is just one of the existant strategies to solve some kind of problems, so it makes no sense asking for a "Standard C code for backtraking". May be this will help you:
Backtraking is basically, a strategy ( often used to solve recursive problems ) in which you advance step by step looking for the solution, until you reach a valid one or a dead end. At this point you go back, and try by another "path". For instance, many problems related with games are solved using backtraking. Imagine a maze. One way of finding a solution to this game is trying all the posible "paths" until you reach a valid solution, completely discarding all paths that leads you to a dead end. This solution is known as "brute force" and its not the "happiest" solution, because you coul be discarding lots of paths that where very near to the solution but they crashed one or two steps before and analyzing others that are early useless. This strategy can be improved by adding backtraking. Using this method, when you find yoursel against a wall, you can go back and try, not from the begining, but from the previous step. And so on.
I hope this may help you understand a bit more about this.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.