Skip to Content
アルゴリズムクイックリファレンス 第2版
book

アルゴリズムクイックリファレンス 第2版

by George T. Heineman, Gary Pollice, Stanley Selkow, 黒川 利明, 黒川 洋
December 2016
Intermediate to advanced
440 pages
9h 44m
Japanese
O'Reilly Japan, Inc.
Content preview from アルゴリズムクイックリファレンス 第2版
74
4
章 整列アルゴリズム
n
が小さいうちは、
ヒープソート
の再帰を省略したことにより目に見える改善があ
るが、
n
が増加するにつれて差異が少なくなる。
4.4
 分割ベースのソート
分割統治戦略は、問題を元の問題のほぼ半分のサイズの
2
つの独立な部分問題
に分けて解決する。この戦略を整列に次のように適用できる。集まり
A
中央値
median
)要素を見つけ、
A
の真ん中の要素と入れ替える。次に、
A[mid ]
より大き
い左半分の要素を
A[mid ]
以下の右半分の要素と入れ替える。これにより、元の配
列は、ほぼ半分のサイズの
2
つの部分配列に分割され、このそれぞれを整列すれば
元の集まり
A
が整列できる。
この方式の実装は、最初に集まりを整列しないで、どのように中央値要素を計算
すればいいのかが明白ではないから、挑戦的である。判明したことは、
A
2
つの
部分配列に分割するには、
A
のどの要素を選んでも構わないということだ。各回で
「賢明に」選ぶなら、両方の部分
配列が多かれ少なかれ同じサイズになり、効率的な
実装が得られる。
関数
p
partition (A, left, right, pivotIndex)
があって、
A
の特別なピボット
A[ pivotIndex ]
を使って、
A
を次のような性質を満たすように変更して、
A
の位置
p
を返すものとする。
A[p ]
pivot
A[left, p)
のすべての要素が
pivot
以下である
A[p
1, right ]
のすべての要素が
pivot
以上である。
運がよければ、 ...
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, 下田 倫大, 長尾 高弘
Rクイックリファレンス 第2版

Rクイックリファレンス 第2版

Joseph Adler, 大橋 真也, 木下 哲也
プログラミングRust 第2版

プログラミングRust 第2版

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall, 中田 秀基
Rではじめるデータサイエンス

Rではじめるデータサイエンス

Hadley Wickham, Garrett Grolemund, 黒川 利明, 大橋 真也

Publisher Resources

ISBN: 9784873117850Other