From ed675a7e2a964376ea5c7bbd51fca45b820c2631 Mon Sep 17 00:00:00 2001 From: jaminleee <91969458+jaminleee@users.noreply.github.com> Date: Tue, 7 Nov 2023 21:14:55 +0900 Subject: [PATCH] =?UTF-8?q?Update=20=EC=84=A0=ED=83=9D=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC(Selection=20Sort).md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\240\225\353\240\254(Selection Sort).md" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git "a/CS Deep Dive/Algorithm/\354\204\240\355\203\235 \354\240\225\353\240\254(Selection Sort).md" "b/CS Deep Dive/Algorithm/\354\204\240\355\203\235 \354\240\225\353\240\254(Selection Sort).md" index d58118a7..d70dc9da 100644 --- "a/CS Deep Dive/Algorithm/\354\204\240\355\203\235 \354\240\225\353\240\254(Selection Sort).md" +++ "b/CS Deep Dive/Algorithm/\354\204\240\355\203\235 \354\240\225\353\240\254(Selection Sort).md" @@ -7,6 +7,16 @@ ![image](https://raw.githubusercontent.com/GimunLee/tech-refrigerator/master/Algorithm/resources/selection-sort-001.gif) +### **예제** +| 패스 | 테이블 | 최솟값 | +|---|---|---| +|0|[9,1,6,8,4,0]|0| +|1|[0,**1,6,8,4,9**]|1| +|2|[0,1,**6,8,4,9**]|4| +|3|[0,1,4,**8,6,9**]|6| +|4|[0,1,4,6,**8,9**]|8| + + ### **시간 복잡도** 데이터의 개수가 n개라고 했을 때, @@ -104,4 +114,16 @@ public class Selection_Sort { } ``` +**[python]** +```python +def selectionSort(x): + length = len(x) + for i in range(length-1): + indexMin = i + for j in range(i+1, length): + if x[indexMin] > x[j]: + indexMin = j + x[i], x[indexMin] = x[indexMin], x[i] + return x +```