zoukankan
html css js c++ java
算法 排序 快速排序
void
QuickSort(SeqList R,
int
low,
int
high)
{
//
对R[low..high]快速排序
int
pivotPos;
//
划分后的基准记录的位置
if
(low
<
high)
{
//
仅当区间长度大于1时才须排序
pivotPos
=
Partition(R,low,high);
//
对R[low..high]做划分
QuickSort(R,low,pivotPos
-
1
);
//
对左区间递归排序
QuickSort(R,pivotPos
+
1
,high);
//
对右区间递归排序
}
}
//
QuickSort
void
QuickSort(
int
[] x,
int
s,
int
t)
{
int
temp;
int
i
=
s, j
=
t;
if
(s
<
t)
{
temp
=
x[s];
do
{
while
(j
>
i
&&
x[j]
>=
temp)
{
j
--
;
}
if
(i
<
j)
{
x[i]
=
x[j];
i
++
;
}
while
(i
<
j
&&
x[i]
<=
temp)
{
i
++
;
}
if
(i
<
j)
{
x[j]
=
x[i];
j
--
;
}
}
while
(i
<
j);
x[i]
=
temp;
QuickSort(x,s,j
-
1
);
QuickSort(x,j
+
1
,t);
}
}
查看全文
相关阅读:
DAS存储未死,再次欲获重生
Minimum edit distance(levenshtein distance)(最小编辑距离)初探
AC自己主动机
手动脱UPX 壳实战
edge中断分析
ubuntu默认的Python版本号修改
Linux 下 pushd,popd,cd- 用法
目标检测算法的历史及分类
openjtag 的硬件连接踩坑历程
ubuntu 16.04 python版本切换(python2和python3)
原文地址:https://www.cnblogs.com/xiaodi/p/296482.html
最新文章
迭代器模式
组合模式
备忘录模式
适配器模式
状态模式
抽象工厂模式
观察者模式
建造者模式
外观模式
模板方法模式
热门文章
原型模式
工厂方法模式
代理模式
装饰模式
策略模式
数据库case,when学习
为pc编译配置安装当前最新的内核
待字闺中之相差甚远面试题分析
Hadoop之MapReduce命令
深入理解Git (三) - 微命令上篇
Copyright © 2011-2022 走看看