"The Big O Binary" Algorithm complexity - Hidden courses


#1

I found this course by accident while googling about this topic :slight_smile:

And I’m stuck on the 11th exercise: Binary. Here’s the code:

var binary = function(n){
var helper = function(i, s){
// If there are no characters left to print, then stop printing
if(i < 1) return [s];

    // array1.concat(array2) is a new array containing the elements of array1 followed by those of array2
    return helper(i-1, "1"+s).concat(helper(i-1, "0"+s));
}

return helper(n, "");

}

console.log(binary(3));

I don’t get the goal of the exercise, where should I print the Big O?

Some help from the support team would be much appreciated, thanks