Page 1 of 1

what is BACKTRACK

Posted: Mon Jun 05, 2006 6:08 pm
by alamit
who can tell me what is BACKTRACK?

Posted: Wed Jun 07, 2006 4:06 pm
by asif_rahman0
The main thing of Backtrack is find all possible way.
Backtrack is nothing just searching for a destination.
Because sometimes its hard to find a destination in normal brute force method for special case.
Suppose.
we have to find value 10 from A[]={9,1,5,2,11,3,4} like the following sequence that we can generate all possible sum of elements from A[].
so our output will be the same as :-
{9,1}=10
{1,5,4}=10
{5,2,3}=10 ...not {2,3,5} it will be wrong..got it alamit!!!:)
{1,2,3,4}=10

Now you have to generate a recursive code like DFS. dont u know DFS??
such as : --recur(index,sum,value)
N.B. : sometimes its not the best selection for problems. Coz Time Limit.
hope u got it.:)

Posted: Thu Jun 08, 2006 6:43 pm
by alamit
thanks
:o :o :o :o :o