0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

いろんなアルゴリズム"00.00.00.01"

Last updated at Posted at 2025-05-04

立ち位置・仕様

  • いろんなアルゴリズムをコピペできるように記録するのみ
  • 最適化が目的でない
  • たまにメモとして解説を残す
  • 最低限でまとめる
  • データを抽出しやすいように個別のIDを付与
  • あるアルゴリズムにおいて、他のアルゴリズムが登場する際にはそのIDを付与
  • IDは16進数表記
  • なるべく最低限なパッケージで実装
  • なるべく特殊なオブジェクト型は使用しない

TargetID

00.00.00.01

ReferenceID

バブルソート

def bubbleSort(l):
    n = len(l)
    for i in range(n):
        for j in range(n-1):
            if l[j] >= l[j+1]:
                tmp = l[j+1]
                l[j+1] = l[j]
                l[j] = tmp
    return l

使用方法

l = [5,2,3,6,2,1]
l = bubbleSort(l):
print(l) # [1, 2, 2, 3, 5, 6]
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?