随笔分类 -  排序

摘要:时间复杂度O(nlogn) 找一个基数,使得这个基数的左边都比它小,右边都比它大。 双指针实现,从左边找找到第一个比基数大下标为i, 从右边找到第一个比基数小的数下标为j,i、j交换。 i == j 时将基数与a[i]交换,分治继续对(l , i-1) 与(i+1 , r)区间进行排序。 //#in 阅读全文
posted @ 2020-02-09 05:28 无名菜鸟1 阅读(157) 评论(0) 推荐(0)
摘要:时间复杂度:O(N2) 进行n-1次挑选,每一次找一个最小的与第一个数交换。 #include<bits/stdc++.h> #define me(x , y) memset(x , y , sizeof(x)) #define SC scanf #define rep(i , j , n) for 阅读全文
posted @ 2020-02-09 05:22 无名菜鸟1 阅读(183) 评论(0) 推荐(0)
摘要:时间复杂度O(N2) 进行n-1次每一次将一个最小的数(或最大的数)归位(最后一个数排好序),两两比较进行交换。 #include<bits/stdc++.h>#define me(x , y) memset(x , y , sizeof(x))#define SC scanf#define rep 阅读全文
posted @ 2020-02-09 05:15 无名菜鸟1 阅读(124) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/bqwzx/p/11029264.html 复杂度为O(n+m)。 特点:消耗空间大最少需要max(数据范围的最大值)个桶去装,但时间时间复杂度是线性的O(n)。 #include<bits/stdc++.h> #define me(x , y) me 阅读全文
posted @ 2020-02-09 05:06 无名菜鸟1 阅读(144) 评论(0) 推荐(0)