From a6272a384d835aa1e5bd0440b478f6f8d2d63e13 Mon Sep 17 00:00:00 2001 From: Sarah Farnsworth-kumli Date: Mon, 31 Jul 2017 19:30:47 -0700 Subject: [PATCH] I remebered how to push --- big_o_exercise/readme.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/big_o_exercise/readme.md b/big_o_exercise/readme.md index c732b1d..f7d5c20 100644 --- a/big_o_exercise/readme.md +++ b/big_o_exercise/readme.md @@ -5,16 +5,25 @@ Simplify the following big O expressions as much as possible: 1. `O(n + 10)` +O(n) 2. `O(100 * n)` +O(n) 3. `O(25)` +0(1) 4. `O(n^2 + n^3)` +O(n^3) 5. `O(n + n + n + n)` +O(n) 6. `O(1000 * log(n) + n)` +O(n) 7. `O(1000 * n * log(n) + n)` +O(nlog(n)) 8. `O(2^n + n^2)` +O(2^n) 9. `O(5 + 3 + 1)` +O(1) 10. `O(n + n^(1/2) + n^2 + n * log(n)^10)` - +O(n^2) ### Part 2 Determine the time and space complexities for each of the following functions. If you're not sure what these functions do, copy and paste them into the console and experiment with different inputs! @@ -28,6 +37,8 @@ function logUpTo(n) { console.log(i); } } +time: O(n) +space: O(1) // 2. @@ -36,6 +47,9 @@ function logAtMost10(n) { console.log(i); } } +time: O(1) +space: O(1) + // 3. @@ -44,6 +58,8 @@ function logAtLeast10(n) { console.log(i); } } +time: O(n) +space: O(1) // 4. @@ -56,6 +72,9 @@ function onlyElementsAtEvenIndex(array) { } return newArray; } +time: O(n) +space: O(n) + // 5. @@ -70,4 +89,5 @@ function subtotals(array) { } return subtotalArray; } +O(n^2) ```