![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
排序
文章平均质量分 97
Yuliang Feng
这个作者很懒,什么都没留下…
展开
-
交换排序之 冒泡排序与快速排序
冒泡排序进行了flag标识,略微提高了排序效率; 快速排序使用递归实现。 import java.util.Random; public class ComparisonSortingAlgorithm { public static void main(String[] args) { Integer[] array = new Integer[10]; Random random = new Random(); for (int i = 0原创 2020-11-09 15:47:37 · 215 阅读 · 0 评论 -
改进的冒泡排序和选择排序(双向冒泡/一次遍历选出最大和最小的选择排序)C语言实现
双向冒泡排序: void doubleBubleSort(int* a, int length) {//双向冒泡排序 int temp; for (int i = length-1,k=0; i > 0; i--,k++) { int j = k; for (; j < i; j++) if (*(a + j + 1) < *(a + j)) { temp = *(a + j); *(a + j) = *(a + j + 1); *(a +原创 2020-12-05 11:41:08 · 1283 阅读 · 0 评论 -
详解初级排序算法(选择、插入、希尔shell)、归并、快速、堆
公共代码 (比较元素大小、将元素在数组中的位置进行交换、判断数组是否已经有序、打印数组) public static boolean less(Comparable v, Comparable w) { return v.compareTo(w) < 0; } public static void exch(Comparable[] a, int i, int j) { Comparable t = a[i]; a[i]原创 2020-11-20 15:39:32 · 735 阅读 · 2 评论