This forum is now read-only. Please use our new forums at discuss.codecademy.com.

# Anyone figured this out yet?

Doesn't make sense to me at all :(

1 vote

console.log("O(n)");

Still have no grasp on BigO =/

wwayne almost 6 years ago

have no grasp on it too...

Eric Summers almost 6 years ago

Big O is a description of how much work an algorithm has to do compared to the size of the input you give it. Try reviewing section 2 of this course keeping that in mind.

Miki almost 6 years ago

This one is a bit harder than U think Eric...

Byron Smith over 5 years ago

Yes, this subject needs to be explained a LOT better for people who are not professional coders to understand. Telling us to review a section that didn't explain things clearly isn't really going to help.

Sofia Perwallius about 4 years ago

Thanks

Here is a dirty way to figure out the "O"....
insert a different counter in each loop...
I used   f,g and h counters;

and then find the largest numbered loop.
After comparing the largest loop with the input number I can calculate the "O".
--------------------------

var f = 1;
var g = 1;
var h = 1;
var printer = function(n){
for(var i = 0; i < n-2; i++){
console.log (f++);
console.log("Warming up printer...");
}
var sum = 0;
for(var j = 0; j < n/2; j++){
console.log (g++);
sum += j;
}
for(var k = 0; k < n; k++){
console.log (h++);
console.log("The sum is: " + sum);
}
};

printer(5);
console.log("O(n)");

----------------------
(The printout a maximum of 5 loops)

1
Warming up printer...
2
Warming up printer...
3
Warming up printer...
1
2
3
1
The sum is: 3
2
The sum is: 3
3
The sum is: 3
4
The sum is: 3
5
The sum is: 3
O(n)

------------------------------