Beyond algorithm complexity

When will you choose an algorithm whose time complexity is O(n^2) instead of the other one whose time complexity is O(n)?

1.When n is small, O(n^2) could be smaller than O(n) or they do not differ much.
2. When time is not a concern and O(n^2) is easy to program.
3. When space complexity is a concern and O(n^2) consume less space.

Advertisements
This entry was posted in Complexity. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s