On 9/11/2011 11:30 PM, Lew wrote:
> Arne Vajhøj wrote:
>> Wanja Gayk wrote:
>>> d says...
>>>> Wanja Gayk wrote:
>>>>> Here's the proof: Sorting an array of positive integers in O(n) time:
> ...
>>>> Very nice! Would you care to try this approach on a shorter
>>>> input array, like
>>>>
>>>> data = new int[] { Integer.MAX_VALUE };
>>>>
>>>> This case should be quite simple, since the array is already sorted.
>>>> Let us know how you make out, will you?
>>>
>>> I didn't say it works for any array out there, did I?
>
> By using big-O notation, you said something about the behavior of the algorithm as the size of the data set tends to infinity, so yes, you did.
>
>> No.
>>
>> But a solution is a bit more practical if it does.
>
> Wanja was making a joke. The performance of an algorithm on one particular data set is irrelevant to a discussion of asymptotic performance. The hub of the joke was his reference to "O(n)" and calling it "proof" when he was making no statement about asymptotic performance.
>
> I get it.
????
Bucket sort is O(n) in n.
Asymptotically for n going against infinity.
Big O for execution speed traditionally does not look at
memory restrictions and data type restrictions.
His code is an example of code - the proof should be in most algorithmic
books.
It is not unheard of for a practical implementation of a sort to have
some limitations.
But usually it is for extreme cases.
Not being able to sort an array with one huge element is
a real problem for practical usage.
Arne