Explain backtracking method using one example.
Answers
Answer:
Backtracking is an algorithmic-technique for solving problems recursively by trying to build a solution incrementally, one piece at a time, removing those solutions that fail to satisfy the constraints of the problem at any point of time (by time, here, is referred to the time elapsed till reaching any level of the ..
Explanation:
Backtracking is one of the most general techniques. In this technique, we search for the set of solutions or optimal solution which satisfies some constraints.
One way of solving a problem is by exhaustive search, we enumerate all possible solutions and see which one produces the optimum result
For example, for the Knapsack problems, we could look at every possible subset objects, and find out one which has the greatest profit value and at the same time not greater than the weight bound.
Backtracking is a variation of exhaustive search, where the search is refined by eliminating certain possibilities. Backtracking is usually faster method than an exhaustive search.