Skip to Content
算法技术手册(原书第2 版)
book

算法技术手册(原书第2 版)

by George T.Heineman, Gary Pollice, Stanley Selkow
August 2017
Intermediate to advanced
360 pages
8h 35m
Chinese
China Machine Press
Content preview from 算法技术手册(原书第2 版)
54
4
排序算法
通过合理的排序预处理,大量的计算任务和作业变得简单。在计算机发展早期,研究人
员将大部分精力放在寻找高效的排序算法上。事实上,很多早期的算法研究都关注于大
数据量的排序,因为早期计算机的内存有限,无法完整地存储那些数据。相比
50
年前的
计算机,现代计算机的能力要强大得多,现今处理的数据量已经达到了太字节(
Terabyte
的级别。尽管不需要手工排序如此海量的数据集,但还是有可能需要对一些略大一点的
数据集进行排序。本章将介绍一些最重要的排序算法,并给出它们的性能评测结果,以
此来帮助读者在各种场景下选最佳的排序算法。
4.1 概述
4.1.1 术语
已知数据集合
A
中的元素可两两比较,现需要对
A
进行排序。我们用
A
[
i
]
a
i
表示这个
集合中的第
i
个元素。按照惯例,集合中的第一个元素被记
A
[0]
。我们使用
A
[
low
,
low
+
n
)
表示包含
n
个元素的子集合
A
[
low
]
A
[
low
+
n
1]
。注
A
[
low
,
low
+
n
]
包含
n
+ 1
个元素。
要排序一个集合,就必须重新组织
A
中的元素以满足如下条件:如
A
[
i
] <
A
[
j
]
,就
i
<
j
如果有重复的元素,那么在结果集合中,这些重复的元素就必须连续地出现。也就是说,
在一个有序的集合中,如果
A
[
i
] =
A
[
j
]
,那么不存在
k
,满足
i
<
k
<
j
并且
A
[
i
]
A
[
k
]
最终,排完序的集合
A
必然是原有集合
A
元素的一个排列。
4.1.2 表示方式
待排序的集合可能已经存储在计算机的随机存储器(
RAM
)中,也有可能只是存储在文 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
Go语言编程

Go语言编程

威廉·肯尼迪

Publisher Resources

ISBN: 9787111562221