Fast algorithm implementation to sort very small list

后端 未结 6 1719
予麋鹿
予麋鹿 2020-11-28 08:42

This is the problem I ran into long time ago. I thought I may ask your for your ideas. assume I have very small list of numbers (integers), 4 or 8 elements, that need to be

6条回答
  •  [愿得一人]
    2020-11-28 09:08

    For such a small data set, you want as simple of algorithm as possible. More likely than not, a basic Insertion Sort will do as well as you could want.

    Would need to know more about the system this is running on, how many times you need to do this sort a second, etc... but the general rule in small sorts is to keep it simple. Quicksort and the like are not beneficial.

提交回复
热议问题