Skip to content

Instantly share code, notes, and snippets.

@Thersis94
Created January 3, 2020 05:18
Show Gist options
  • Save Thersis94/6e5889c1a1aedae0d58e3c6c4579177e to your computer and use it in GitHub Desktop.
Save Thersis94/6e5889c1a1aedae0d58e3c6c4579177e to your computer and use it in GitHub Desktop.
1. What is the Big O for this?
a. O(1)
b. O(n)
2. Even or odd O(1) Always going to take the same amount of time for each input
3. Are you here? O(n^2) Nested loops each run from 0 to n the outer loop runs the inner loop n times and each time the inner loop will run n times
4. Doubler O(n) Just runs one loop and there for will always take the same amount of time per input
5. Naive search O(n) Just runs one loop and there for will always take the same amount of time per input
6. Creating pairs O(n^2) Nested loops each run from 0 to n the outer loop runs the inner loop n times and each time the inner loop will run n times
7. Compute the sequence O(n) Just runs one loop and there for will always take the same amount of time per input
8. An efficient search O(log(n)) this example maximizes efficiency by narrowing down the possible
9. Random element O(n) it could be the first try it could be the last try, this solution is completely random so it isnt very efficent
10. What am I? O(n) Jus=t runs one loop and there for will always take the same amount of time per input, this algorithm could be slightly more efficent because it reduces the incoming variables before spending the required time to run it through the loop
T(1) = O(1) T(1.1) = O(n) T(2) = O(1) T(3) = O(n^2) T(4) = O(n) T(5) = O(n) T(6) = O(n^2) T(7) = O(n) T(8) = O(log(n)) T(9) = O(1) T(10) = O(n) T(11) = O(n^2) T(12) = O(n) T(13) T(1) = O(1) T(2) = O(1) T(3) = O(n) T(4) = O(n) T(5) = O(n) T(6) = O(n) T(7) = O(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment