什么是最好的排序算法为一组随机漂浮物? [英] What is the best sort algorithm for a random set of floats?

查看:134
本文介绍了什么是最好的排序算法为一组随机漂浮物?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一位同事只是把这个问题出在空中今天下午,有点让我好奇。我精通分拣交易算法,但缺少一个正式的学位compsci / compeng(这是我八九不离十不愿意承认),真的不能把我的手指在这一个。 :P

A colleague of mine just put that question out in the air this afternoon, and somewhat left me curious. I'm versed with sorting algos, but lacking a formal degree in compsci / compeng (something I'm sorta averse to admitting), can't really place my finger on this one. :p

和噢,这是轻度的一个C#/。NET实现...的背景下,以防万一,改变的事情一点。

And oh yeah, this is mildly in the context of a C#/.NET implementation... just in case that changes things a bit.

谢谢你们。 :)

推荐答案

对于固定长度的数字,你不局限于基于比较的排序算法,所以 O(N *的log(n) )没有的限制。 基数排序 O(n)的工作原理,可用于比较方便由于IEEE 754浮点数被正确地排序时,他们的位模式为PTED为整数除$ P $,惊人的属性

For fixed-length numbers, you're not restricted to comparison-based sorting algorithms, so O(n*log(n)) is not the limit. Radix Sort works in O(n), and can be used quite conveniently due to the amazing property of IEEE 754 floats of being sorted correctly when their bit pattern is interpreted as integers.

这篇关于什么是最好的排序算法为一组随机漂浮物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆