diff --git a/big_o_exercise/readme.md b/big_o_exercise/readme.md index c732b1d..41852a6 100644 --- a/big_o_exercise/readme.md +++ b/big_o_exercise/readme.md @@ -4,16 +4,26 @@ Simplify the following big O expressions as much as possible: -1. `O(n + 10)` +1. `O(n + 10)` +// O(n) 2. `O(100 * n)` -3. `O(25)` +// O(n) +3. `O(1)` +// O(n) 4. `O(n^2 + n^3)` +// O(n^3) 5. `O(n + n + n + n)` +// O(n) 6. `O(1000 * log(n) + n)` +// log(n) 7. `O(1000 * n * log(n) + n)` +// nlog(n) 8. `O(2^n + n^2)` +// O(n^2) 9. `O(5 + 3 + 1)` +// O(1) 10. `O(n + n^(1/2) + n^2 + n * log(n)^10)` +// O(n^2) ### Part 2 @@ -29,6 +39,12 @@ function logUpTo(n) { } } + +time: O(n) +space: O(1) + + + // 2. function logAtMost10(n) { @@ -37,6 +53,10 @@ function logAtMost10(n) { } } +time: O(1) +space: O(1) + + // 3. function logAtLeast10(n) { @@ -45,6 +65,9 @@ function logAtLeast10(n) { } } +time: O(n) +space: O(1) + // 4. function onlyElementsAtEvenIndex(array) { @@ -57,6 +80,10 @@ function onlyElementsAtEvenIndex(array) { return newArray; } +time: O(n) +space: O(n) + + // 5. function subtotals(array) { @@ -70,4 +97,8 @@ function subtotals(array) { } return subtotalArray; } + +time: O(n^2) +space: O(n) + ``` diff --git a/readme.md b/readme.md deleted file mode 100644 index 3a349ce..0000000 --- a/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -## JavaScript Computer Science Exercises - -- [Recursion Exercise](./recursion_exercise) -- [Searching Algorithms Exercises](./searching_algorithms_exercise) -- [Sorting Algorithms Exercises](./sorting_algorithms_exercise) -- [Singly Linked Lists Exercises](./singly_linked_lists_exercise) -- [Doubly Linked Lists Exercises](./doubly_linked_lists_exercise) -- [Stacks Exercises](./stacks_exercise) -- [Queues Exercises](./queues_exercise) -- [Binary Search Trees Exercises](./binary_search_trees_exercise) -- [Binary Heaps Exercises](./binary_heaps_exercise) -- [Hash Tables Exercises](./hash_tables_exercise) -- [Graphs Exercises](./graphs_exercise) \ No newline at end of file