Created
December 23, 2018 18:02
-
-
Save arrbxr/94cf2199d6ea8d38ceb10a0f0561dfe2 to your computer and use it in GitHub Desktop.
BigO Exercise 1 created by arrbxr - https://repl.it/@arrbxr/BigO-Exercise-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What is the Big O of the below function? (Hint, you may want to go line by line) | |
function funChallenge(input) { | |
let a = 10; // O(1) | |
a = 50 + 3; // O(1) | |
for (let i = 0; i < input.length; i++) { // O(n) here n -> number of input | |
anotherFunction(); // O(n) | |
let stranger = true; // O(n) | |
a++; // O(n) | |
} | |
return a; // O(1) | |
} | |
// So here big o notaion is | |
// 3 + n + n + n + n | |
// BIG O(3 + 4n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment