码迷,mamicode.com
首页 >  
搜索关键字:selection sort 选择排序    ( 16342个结果
Collections -- 集合的工具类
Collections是JDK针对集合提供的一个工具类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。1、搜索如可以使用Collections提供的二分查找方法binarySearch()2、排序如可以使用Collections.sort()对List进行了排序3、线程安全化使用...
分类:其他好文   时间:2014-06-09 21:34:32    阅读次数:175
python实现冒泡排序
代码#!/usr/bin/python#-*-coding:utf-8-*-#----------------------------------------------------------------------------------------# to_do : bubble sort#....
分类:编程语言   时间:2014-06-08 23:51:58    阅读次数:461
实例365(13)---------经典数组排序方法------选择排序法
一:使用选择排序法对一维数组进行排序,截图/*选择排序的个人理解: 第一遍筛选,选出其中最大的值,得到值和下标 将最大的值的位置和数组的第一个位置交换 从数组的第二个位置开始第二遍筛选 将其中最大的值的位置和数组的第二个位置交换 直到筛选完数组 */二:代码using Syste...
分类:其他好文   时间:2014-06-08 21:01:12    阅读次数:264
[leetcode]Sort Colors @ Python
原题地址:https://oj.leetcode.com/problems/sort-colors/题意:Given an array withnobjects colored red, white or blue, sort them so that objects of the same col...
分类:编程语言   时间:2014-06-08 20:56:32    阅读次数:394
定制对ArrayList的sort方法的自定义排序
java中的ArrayList需要通过collections类的sort方法来进行排序如果想自定义排序方式则需要有类来实现Comparator接口并重写compare方法调用sort方法时将ArrayList对象与实现Commparator接口的类的对象作为参数示例:// 外部类的方式import ...
分类:其他好文   时间:2014-06-08 19:10:21    阅读次数:221
一入python深似海--split
下面说说split函数的用法 def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ')#split('.',1) use '.' split one time return words def sort_words(wo...
分类:编程语言   时间:2014-06-08 18:19:21    阅读次数:336
普林斯顿公开课 算法3-9:Comparator比较器
在前几个章节中使用了Comparable作为比较函数。比如对于字符串,就是按字母表的顺序进行排序。有时候想要换一种比较方式,该怎么实现呢? 在Java中可以使用Comparator比较器,以下代码展示了字符串之间不同的比较方式。 String[] a; ... Arrays.sort(); ... Arrays.sort(a, String.CASE_INSENSITI...
分类:其他好文   时间:2014-06-08 15:37:08    阅读次数:201
探讨排序算法的实现
排序算法是我们工作中使用最普遍的算法,常见的语言库中基本都会有排序算法的实现,比如c标准库的qsort,stl的sort函数等。本文首先介绍直接插入排序,归并排序,堆排序,快速排序和基数排序等比较排序算法,然后介绍计数排序,基数排序等具有线性时间的排序算法。本文主要讨论算法的实现方法,并不会过多介绍...
分类:其他好文   时间:2014-06-07 21:23:31    阅读次数:348
排序算法--(二)
选择排序 直接选择排序: 选择排序,每一趟找到一个最小(大)值,每一趟遍历的数据减少一次。 template void SelectSort(T a[],int length){ T temp; for (int i=0;i0;i--) { shift(a,i,n); //n只是起条件判断作用,并不...
分类:其他好文   时间:2014-06-07 21:10:36    阅读次数:210
leetcode--Sort Colors
Given an array withnobjects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, wh...
分类:其他好文   时间:2014-06-07 20:11:53    阅读次数:234
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!