DFS
T0: Find all permutation, combination, etc.. How to avoid producing duplicate results:
T1: Modify an object to meet with the requirements. List all the results.
List<String> result = new ArrayList<>();
// f(i) element at index i force the program into next recursion
// Op(j) if operation on the element at index j safisfies the requirment
public void helper(int last_modified, int last_checked, String s) {
for(int i = last_checked+1; i<s.length(); i++) {
if(f(i)) {
for(int j=last_checked+1; j<=i; j++) {
if(op(j)) helper(j,i,s);
}
return;
}
}
result.add(s); // now, add the result here
}T2: Two DFS ways (Broader VS Deeper):
T3: Iterative DFS
T4: Subset and Subsequence
Last updated