diff --git a/Recursion and Backtracking/Recursion_new.md b/Recursion and Backtracking/Recursion_new.md index ada3db1..eafff29 100644 --- a/Recursion and Backtracking/Recursion_new.md +++ b/Recursion and Backtracking/Recursion_new.md @@ -52,7 +52,7 @@ def pow(n, k): Why not f(n, k/2) * f(n, k/2+1) in the else condition? To allow reuse of answers. - + __Time Complexity__ (assuming all multiplications are O(1))? $O(\log_2 k)$ @@ -87,7 +87,7 @@ def subsets(A, i, aux): ``` - How many leaf nodes? $2^n$ - one for each subset @@ -149,11 +149,11 @@ For Array [0,1,2,3,4] Subsets in Lexicographical order, But don't print when going left - because already printed in parent. - - ```python def subsets(A, i, aux, p): @@ -180,7 +180,7 @@ The subsetSum problem can be divided into two subproblems. - Exclude the current element from the sum and recur (i = i + 1) for the rest of the array. - ```python def subsetSum(A,N,cur_sum, i, target): @@ -211,7 +211,10 @@ Number of Subsets with a given Sum (Repetition Allowed) The subsetSum2 problem can be divided into two subproblems. - Include the current element in the sum and recur for the rest of the array. Here the value of i is not incremented to incorporate the condition of including multiple occurances of a element. - Exclude the current element from the sum and recur (i = i + 1) for the rest of the array. -![IMG_0040](https://user-images.githubusercontent.com/35702912/66470200-c27db600-eaa6-11e9-8744-ca572d6000e1.jpg) + + + ```python def subsetSum2(A,N,cur_sum, i, target): if i == N: