摘要: include<bits/stdc++.h> using namespace std; template int Partition(T a[],int low,int height){ T pivot=a[low];//这个要用T,因为你不知道这个是什么类型的数据 while(low<height 阅读全文
posted @ 2026-03-04 21:07 Time_q 阅读(4) 评论(0) 推荐(0)
摘要: 快速排序优化:随机化基准值避免复杂度退化 为什么需要随机化选取基准值? 选第一个元素作为基准:升序/降序数组会让快排复杂度退化为 O(n²) 选中间元素作为基准:存在 "Anti-QuickSort" 恶意数据,同样会退化为 O(n²) 随机化基准:从根本上避免被构造的数据 Hack,保证平均 O( 阅读全文
posted @ 2026-03-04 20:40 Time_q 阅读(9) 评论(0) 推荐(0)