调整这个计数排序算法(伪代码)来对 n 个十进制数字的序列进行排序?
是否可以采用计数排序的伪代码来对十进制数序列进行排序?
就像我要给你一个由 n 个十进制数组成的序列 A (1.897, 2.34, 76.9834, 5... )并且我们还假设这些值最多有 4 位小数...是否可以修改此计数排序来对序列进行排序?
在我看来,使用计数排序实现基数排序不是显而易见的吗?选择实现这一点......或者这只适用于整数?
If I were to present you with this counting sort algorithm:
Would it be possible to adapt this pseudocode for Counting Sort to sort a sequence of decimal numbers?
Like if I was to give you a sequence A of n decimal numbers (1.897, 2.34, 76.9834, 5...) and let's also say these values have at most 4 decimals...would it be possible to modify this Counting Sort to sort the sequence?
In my mind, wouldn't implementing Radix Sort with counting sort be the obvious choice to make this happen...or would this only work for integers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论