What is the fastest sorting algorithm for a small number of integers?

后端 未结 12 3218
青春惊慌失措
青春惊慌失措 2021-02-20 18:45

I am wondering what the fastest algorithm would be for this. I have 8 integers between 0 and 3000 and I need to sort them. Although there are only 8 integers, this operation w

12条回答
  •  不要未来只要你来
    2021-02-20 19:29

    I ran a library of sort algorithms against all permutations of {0, 429, 857, 1286, 1714, 2143, 2571, 3000}.

    The fastest were:

    name                                time   stable in-place
    AddressSort                         0.537   No      No
    CenteredLinearInsertionSort         0.621   Yes     No
    CenteredBinaryInsertionSort         0.634   Yes     No
    BinaryInsertionSort                 0.639   Yes     Yes
    ...
    QuickSort                           0.650   No      Yes
    ...
    BubbleSort                          0.802   Yes     Yes
    

    For more on AddressSort see http://portal.acm.org/citation.cfm?id=320834

提交回复
热议问题