数据结构基础(9)------------简单选择排序(Simple Selection Sort)
2014-03-21 14:13
337 查看
数据结构基础(9)------------简单选择排序(Simple Selection Sort)
1.简单选择排序:就是通过n-i次关键字比较,从n-i-+1个记录中找出关键字最小的记录,并和第i个记录进行交换;
1.简单选择排序:就是通过n-i次关键字比较,从n-i-+1个记录中找出关键字最小的记录,并和第i个记录进行交换;
void SimpleSelectionSort(int *a,int len) //此算法其实与冒泡排序的第一个思想比较雷同,之前的那个算法 { int temp=0; //比较的同时,也在进行移位,而此算法,只是在寻找最小的记录的下标 for (int i=0;i<len;++i) //对于次外循环来说,仅需要交换一次数据,其最大的特点的就是交换移 //动次数很少,故而其在一定的程序上,还是优于冒泡排序的! { int min=i; for (int j=i+1;j<len;++j) { if (a[min]>a[j]) { min=j; } } if (min!=i) { int temp=a[i]; a[i]=a[min]; a[min]=temp; } } }
相关文章推荐
- [php]数据结构&算法(PHP描述) 简单选择排序 simple selection sort
- 选择排序—简单选择排序(Simple Selection Sort)原理以及Java实现
- 简单选择排序(Simple Selection Sort)
- 中国大学MOOC-数据结构基础习题集、08-3、Sort with Swap(0,*)
- 简单选择排序(Simple Selection Sort)
- PHP排序算法之简单选择排序(Simple Selection Sort)实例分析
- 数据结构 - 简单选择排序(simple selection sort) 详解 及 代码(C++)
- 八大排序算法之三选择排序—简单选择排序(Simple Selection Sort)
- 【数据结构与算法基础】单链表及其应用基数排序 / Singly Linked List and radix sort
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- 选择排序—简单选择排序(Simple Selection Sort)
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- 冒泡排序(bubble sort)、直接插入排序(straight insertion sort)、简单选择排序(simple selection sort)
- 选择排序—简单选择排序(Simple Selection Sort)
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- 简单选择排序(Simple Selection Sort)
- 选择排序—简单选择排序(Simple Selection Sort)
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
- PHP简单选择排序(Simple Selection Sort)算法学习