Does a “binary sort” algorithm exist?

前端 未结 8 1159
孤独总比滥情好
孤独总比滥情好 2021-01-07 21:59

Is there a sorting algorithm that is named \"binary sort\"? Like merge sort, selection sort, or the other kinds of sorting, does a binary sort exist?

相关标签:
8条回答
  • 2021-01-07 22:46

    There's this and there's binary insertion sort. The two are pretty similar. They're both quadratic (O(n^2)) time algorithms.

    Both algorithms do O(n log n) number of comparisons, but in practice you would also have to move elements around, which would make the entire algorithm quadratic.

    0 讨论(0)
  • 2021-01-07 22:46

    A binary sort is a very fast algorithm which involves bit testing. It has a single pass for each bit in the sortable item. For each pass, if the bit is set then the sortable item is stacked at one end of the buffer. If the bit is not set then the item is stacked at the other end of the buffer. Starting the sort at the least significant bit and dealing with the next bits in ascending order will result in the sorted list. I wrote one of these on an early 8086 in 1983 forthe Scottish Education Department. Steve Pitts

    0 讨论(0)
  • 2021-01-07 22:47

    We do not have a binary sort algorithm, but we do have binary search on a sorted array.

    0 讨论(0)
  • 2021-01-07 22:48

    Not sure what your looking for but if your looking for a suitable binary sort algorithm then you want to be aware of your requirements. Each algorithm has its own strengths and weakness.

    For example, are you looking for an algorithm that give fastest average performance (e.g. heap search) or fasted worst case (slowest operation) performance (e.g. balanced binary tree). Some are slow if you also need to iterate from one item to the next. If your doing many random operations you are probably more interested in average performance but if you have a need to ensure that any operation is faster than X milliseconds then you may want a different algorithm. Some can be slow if you always adding items at the end of the collection etc.

    So have a google for keywords like:

    • Red black tree
    • heap search
    • balanced trees, e.g. http://www.codeproject.com/KB/recipes/redblackcs.aspx?msg=931557

    It all comes down to what you need.

    0 讨论(0)
  • 2021-01-07 22:51

    There are some sort's that involve splitting into two peices (merge sort) but I don't beleive that there is a sort called exactly "binary sort".

    0 讨论(0)
  • 2021-01-07 22:51

    There can be a binary sort but the actual array sorted should be in Opposite sense.(i.e., Say you want to sort an array of integers in ascending order...for that, you must have the actual array in descending order.)

    0 讨论(0)
提交回复
热议问题