---
id: "imported/ps/algorithm/sort/bubble"
title: "Bubble Sort"
description: "Bubble Sort 관련 기록."
kind: "record"
published: "2023-08-07T00:00:00.000Z"
tags: []
url: "https://www.readiz.com/notes/algorithm/sort/bubble/"
markdownUrl: "https://www.readiz.com/notes/algorithm/sort/bubble/index.md"
---

# Bubble Sort

## Bubble Sort

```cpp
void sort() {
    for(int i = 0; i < N; ++i) {
        for(int j = i + 1; j < N; ++j) {
            if (data[i] > data[j]) {
                auto tmp = data[i];
                data[i] = data[j];
                data[j] = tmp;
            }
        }
    }
}
```

## Time Complexity

- Average: $O(N^2)$
- Worst: $O(N^2)$
