---
title: "Discussion on \"Algorithm 演算法 - 排序系列 Bubble sort 氣泡排序\" | Hashnode"
description: "Discussion on \"Algorithm 演算法 - 排序系列 Bubble sort 氣泡排序\". Bubble sort 其原理是反覆的進行「由右至左，相鄰的值兩兩比較後重新排序」。因其向水中泡泡浮起的樣子，所以以此得名。\n其複雜度是，第一回執行 n-1、第二回執行 n-2 依序到第 n-1 回執行 1 次。\n(n-1) + (n-2) + ... + 1 = n^2 / 2。\n時間複雜度：O(n^2)\n程式範例\nGo\nfunc bubbleSort(arr []int) []int {\n    length := len(arr)\n    for i := 0; i < length; i..."
url: "https://hashnode.com/posts/algorithm-bubble-sort/6133759092d0321a9999219e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Algorithm 演算法 - 排序系列 Bubble sort 氣泡排序](https://blog.taiwolskit.com/algorithm-bubble-sort?utm_source=hashnode&utm_medium=feed)

Bubble sort 其原理是反覆的進行「由右至左，相鄰的值兩兩比較後重新排序」。因其向水中泡泡浮起的樣子，所以以此得名。 其複雜度是，第一回執行 n-1、第二回執行 n-2 依序到第 n-1 回執行 1 次。 (n-1) + (n-2) + ... + 1 = n^2 / 2。 時間複雜度：O(n^2) 程式範例 Go func bubbleSort(arr \[\]int) \[\]int { length := len(arr) for i := 0; i < length; i...

Sep 4, 2021 · 2 min read · blog.taiwolskit.com  
Updated Feb 13, 2022  
Read the article

-   [#algorithms](https://hashnode.com/tag/algorithms)

## Written by

[攻城獅](https://hashnode.com/@taiwolskit)

@taiwolskit · Tokyo

  
[View profile](https://hashnode.com/@taiwolskit)

一個很油的不工程的攻城獅，喜歡不務正業、各式新奇的東西。看看網路行銷、政治議題、二次元世界 Peko

I am not a programmer just a leaner. Writing JavaScript, Python, and Go and doing something on Kubernetes.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
