How is O(N) algorithm also an O(N^2) algorithm? | Solution

"Upper bound" means the algorithm takes no longer than (i.e. <=) that long (as the input size tends to infinity, with relevant constant factors considered). It does not mean it will ever actually take that long. Something that's O(n) is also O(n log n), O(n2), O(n3), O(2n) and also anything else that's asymptotically bigger than n. If you're comfortable with the relevant mathematics, you can also see this from the formal definition.

No comments:

Post a Comment

latest ECMAScript proposals and releases (as of ECMAScript 2024), several enhancements have been made to built-in objects like Set

JavaScript continues to evolve, and in the latest ECMAScript proposals and releases (as of ECMAScript 2024), several enhancements have been ...

Best for you