summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-11-07 20:01:23 -0700
committermo khan <mo@mokhan.ca>2021-11-07 20:01:23 -0700
commit575b7cbdbefca2aab2ce004465b126d0e1b89d36 (patch)
tree92be8a9f82d8aae366ed09a125edf708c0af5350
parentf25f6ed3f80f3b73a6a9da0885926c1faf61052d (diff)
use the substitution method
-rw-r--r--0x01/README.md14
1 files changed, 12 insertions, 2 deletions
diff --git a/0x01/README.md b/0x01/README.md
index c84cecc..7d6f7b1 100644
--- a/0x01/README.md
+++ b/0x01/README.md
@@ -382,14 +382,24 @@ Big O notation says:
> if there exists positive constants `c` and `n0`
> such that `0 <= f(n) <= c*g(n)` for all `n >= n0`.
+
```plaintext
For this equation `T(n) = T([n/2]) + 1` to be bounded by `O(lg n)`
we would have to prove that the following is true.
+We can also use the substitution method to make a guess as the starting point.
+Since we are trying to prove for `O(lg n)` we can start with this.
+
0 <= f(n) <= c * lg(n/2) + 1
-We can't reduce this further and choosing a positive constant c
-doesn't allow us to satisfy the constraint of the function.
+This isn't enough for us to make the proof so we can try to introduce `d` where
+`d >= 1`. This allows us to rewrite the above as:
+
+ 0 <= f(n) <= c * lg(n/2) + 1 - d
+ if d = 1 then we can drop the constant.
+ 0 <= f(n) <= c * lg(n/2)
+
+This allows us to make the claim that this function is bounded by `O(lg n)`.
```
## Exercise 4.4-7 from the textbook (10 marks)