0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

データの整列

Posted at

データの整列

整列とは、ある規則に従いデータを並べ替えること。ソートともいわれている。
小さなものから大きなものに並べ替える昇順、大きなものから小さなものに並べ替える降順がある。

代表的な整列法

基本交換法(バブルソート・隣接交換法)

隣あうデータを比較し、逆順であれば入れ替える。
比較回数はN(N-1)/2

基本選択法

データ列の最小値(最大値)を選択して入れ替え、次にそれを除いた部分の中から最小値(最大値)を選択して入れ替える。
比較回数はN(N-1)/2

基本挿入法

既に整列済みのデータの正しい位置に、データを挿入する。
比較回数はN(N-1)/2だが、元の並び方次第でこれ以下になる。

その他の整列法

シェルソート(改良挿入法)

ある一定間隔おきに取り出したデータから成るデータ列をそれぞれ整列する。
次に、間隔が1になるまで繰り返すのがシェルソート

クイックソート

適当な基準値を決め、それより小さいグループと大きなグループに振り分ける。

ヒープソート

未整列の部分を順序木に構成し、その最大値(最小値)を取り出して、既整列の部分に移す。
こうして未整列部分を縮めていくもの。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?