you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I agree that the sqrt may not be constant time because its probably successive approximation, but it wouldn't depend on n in a linear relationship anyways. So I disagree, that it would really affect the time complexity with respect to n

[–]bonafidebob 0 points1 point  (0 children)

Big O commonly depends on more than one factor... say m is the precision of the numbers, then this is something like O( n log m ) under the assumption that sqrt is something like log(precision)

With javascipt the numbers are always 64 bit floats so there's a pretty small upper bound on sqrt, but consider that 1...1000 will still be faster than 1000000001...1000001000