Created
December 23, 2018 18:10
-
-
Save arrbxr/8ff4091427c55917e9aed318553e55e1 to your computer and use it in GitHub Desktop.
BigO Exercise 2 created by arrbxr - https://repl.it/@arrbxr/BigO-Exercise-2
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 anotherFunChallenge(input) { | |
let a = 5; // O(1) | |
let b = 10;// O(1) | |
let c = 50;// O(1) | |
for (let i = 0; i < input; i++) { | |
let x = i + 1; // O(n) | |
let y = i + 2; // O(n) | |
let z = i + 3; // O(n) | |
} | |
for (let j = 0; j < input; j++) { | |
let p = j * 2; // O(n) | |
let q = j * 2; // O(n) | |
} | |
let whoAmI = "I don't know"; // O(1) | |
} | |
// so, BIG O(4 + 5n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment