answersLogoWhite

0

An algorithm that takes infinite time is the slowest. If the time complexity is O(infinity) then the algorithm may never produce a result. Algorithms with O(infinity) complexity are of no practical use whatsoever, other than to demonstrate how not to write an algorithm.

As an example, consider an algorithm that sorts elements in an illogical manner, such as by shuffling the elements randomly and then testing to see if they are in the correct order. If you can imagine a deck of 52 playing cards you will know how impossible it is to shuffle the cards and get them all in the correct order.

An algorithm doesn't need to have O(infinity) complexity to be considered useless for practical purposes. Bubblesort is a typical example of a useless algorithm. It has an average time complexity of O(n^2) (where n is the number of elements) which is considered reasonable for a small set of data but is impractical for large sets. However, it is not the time complexity that is the problem, it is the sheer number of swapping operations required upon each iteration. Insert sort has the same time complexity but is significantly faster on average because it has no swap operations. Even so, it has no practical uses because, like Bubblesort, it is only suitable for relatively small sets. For practical sorting purpose you need a non-linear algorithm with a time complexity of O(n log n) and, in this respect, hybrid sorts like Introsort win hands-down.

User Avatar

Wiki User

10y ago

What else can I help you with?