MCPcopy Create free account
hub / github.com/Flamewaker/JavaPersonalSummary / bucketSort

Method bucketSort

Code/leetcode/Sort/Sort.java:130–141  ·  view source on GitHub ↗

桶排序 - 实现线性排序,但当元素间值得大小有较大差距时会带来内存空间的较大浪费。首先,找出待排序列中得最大元素max,申请内存大小为max + 1的桶(数组)并初始化为0;然后,遍历排序数列,并依次将每个元素作为下标的桶元素值自增1; 最后,遍历桶元素,并依次将值非0的元素下标值载入排序数列(桶元素>1表明有值大小相等的元素,此时依次将他们载入排序数列),遍历完成,排序数列便为有序数列。 时间复杂度:O(x N) 稳定性:稳定 @param arr

(int[] arr)

Source from the content-addressed store, hash-verified

source not stored for this graph (policy: none)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected