From f700d74ba14ebb5d591656168040c4c2688d123a Mon Sep 17 00:00:00 2001
From: Riya Bansal <35702912+riyabansal98@users.noreply.github.com>
Date: Sat, 12 Oct 2019 16:20:51 +0530
Subject: [PATCH] Fix: Minor indentation Changes
---
Recursion and Backtracking/1.md | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Recursion and Backtracking/1.md b/Recursion and Backtracking/1.md
index eafff29..0ebe175 100644
--- a/Recursion and Backtracking/1.md
+++ b/Recursion and Backtracking/1.md
@@ -23,7 +23,7 @@ __Intuition__
The main idea is to represent a problem in terms of one or more smaller problems, and add one or more base conditions that stop the recursion.
_For example_, we compute factorial n if we know factorial of (n-1). The base case for factorial would be n = 0. We return 1 when n = 0.
--- --
+
Power
-----
@@ -35,7 +35,7 @@ def pow(n, k):
if k == 0: return 1
return n*pow(n, k - 1)
```
-__Time Complexity__: $O(n)$
+__Time Complexity__: O(n)
__Optimised solution:__
```python
@@ -54,7 +54,7 @@ To allow reuse of answers.
-__Time Complexity__ (assuming all multiplications are O(1))? $O(\log_2 k)$
+__Time Complexity__ (assuming all multiplications are O(1))? O(\log_2 k)$O(\log_{2}k)$
Break it into 3 parts? k//3 and take care of mod1 and mod2.
@@ -71,7 +71,7 @@ The idea is to consider two cases for every element.
(i) Consider current element as part of current subset.
(ii) Do not consider current element as part of current subset.
-Number of subsets? $2^n$
+Number of subsets? $2^{n}$
Explain that we want combinations, and not permutations. [1, 4] = [4, 1]
@@ -164,7 +164,7 @@ def subsets(A, i, aux, p):
no_take = subsets(A, i+1, aux, False)
```
-__Time Complexity__: $O(2^n)$
+__Time Complexity__: $O(2^n)$
__Space Complexity__: $O(n^2)$, because we're creating new aux arrays.
-- --
@@ -228,7 +228,7 @@ def subsetSum2(A,N,cur_sum, i, target):
no_take = subsetSum2(A,N,cur_sum, i+1, target)
return take + no_take
```
-__Time Complexity__ : $O(2 ** (Target/MinElement))$
+__Time Complexity__ : $O(2 ** (Target/MinElement))$
__Space Complexity__: $O(Target/Min Element)$