Which to use and when? And what are the advantages of one approach over the other?
Permutation brute force is the one in which at each recursion step, we can enter any of the array elements. If repeats are not allowed, we maintain a "visited" memo(as in DFS), if repeats are allowed, we don't need the "visited" memo
f(arr,target) -> for x in arr: f(arr,target-x)
Selection brute force is the one in which at each recursion step, we only enter a particular array element. If repeats are not allowed, we select the current element 0/1 times(0/1 knapsack). If repeats are allowed, we select the current element 0,1,2,... times(unbounded knapsack).
f(arr,i,n) -> f(arr,i+1,n)
I have seen that in the case of DP, if both options are available cleanly, it is better to use permutation brute force, because it creates a cleaner induction hypothesis because we dont have to involve index of supposedly "current element". Or else use the other.
But in case of backtracking, or if we need to GENERATE ALL SUBSETS, it is better to use selection brute force, because the know ordering helps eliminate the cases of repeated elements in our final answer.
I am confused about when to use what, and what are the advantages and disadvantages of one over the other. What will you prefer and when?