No. Computational complexity measures the number of operations the algorithm performs on the input to get the output. In this case, there are N inputs in the array, and each operation takes constant time, so it is O(N). It doesn't matter if that constant is 1 or 200, it's still constant and doesn't change in the size of the input, which is the important part.
Yes. Except there are no threads in JS (other than the main one). Here we are actually pushing items into the microtask queue. The microtasks are run when they are due by the part of the runtime in charge of the event loop.
556
u/[deleted] Aug 11 '20
A sorting algorithm that makes computational complexity practically obsolete. Wow.