桶排序 Java 代码


桶排序 代码

/* Copyright (c) 2012 the authors listed at the following URL, and/or
the authors of referenced articles or incorporated external code:
https://en.literateprograms.org/Bucket_sort_(Java)?action=history&offset=20090316075127
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Retrieved from: https://en.literateprograms.org/Bucket_sort_(Java)?oldid=16280
*/
import .util.Arrays;
public class Bucketsort {
  public static int[] bucketSort(int[] arr) {
    int i, j;
    int[] count = new int[arr.length];

      count[arr[i]]++;
    }

      for(; count[i]>0; (count[i])--) {
        arr[j++] = i;
      }
    }
    return arr;
  }
  public static void main(String[] args) {
    int[] arr = new int[] {1,3,4,6,4,2,9,1,2,9};

      System.out.print(arr[i] + " ");
    }
    System.out.println();
    arr = bucketSort(arr);

      System.out.print(arr[i] + " ");
    }
    System.out.println();
  }
}

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《桶排序 Java 代码
本文地址:https://www.zhiletu.com/archives-7825.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微