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);
}
}
查看全文
相关阅读:
pm2日志切割
PM2常用命令
Linux安装nodejs
npm 修改源地址
nodejs 生成验证码
shell脚本解析json文件
mysql添加用户并赋予权限命令
Redis 配置密码
JavaScript也是黑客技术?
angular和vue的对比学习之路
原文地址:https://www.cnblogs.com/xiaodi/p/296482.html
最新文章
1078. Hashing (25)
1075. PAT Judge (25)
KVM安装启动虚拟机
ubuntu14.04安装tun/tap网络设备
1084. Broken Keyboard (20)
1081. Rational Sum (20)
1053. Path of Equal Weight (30)
1071. Speech Patterns (25)
Windows版本搭建安装React Native环境配置
vscode部分文件夹无法打开
热门文章
【转】idea激活搭建授权服务器
【mysql】count(*),count(1)与count(column)区别
浅谈HTTPS连接
2017.8.17
RSA前端JS加密,后端JAVA解密实现
Immutable学习及 React 中的实践
js获取三天后的日期
React创建组件的三种方式比较和入门实例
linux 编译安装php7
php安装扩展
Copyright © 2011-2022 走看看