Selection Sort

2023. 5. 10. 15:28· 자료구조 알고리즘/이론
목차
  1. 시간복잡도
  2. 공간복잡도
  3. 장점
  4. 단점
  5. References

해당 순서에 원소를 넣을 위치는 이미 정해져 있고, 어떤 원소를 넣을지 선택하는 알고리즘

최소값을 찾고 위치 값과 교환. 나머지도 같은 방법으로 교체.

A = [64, 25, 12, 22, 11]
for i in range(len(A)):
	min_idx = i
    for j in range(i+1, len(A)):
    	if A[min_idx] > A[j]:
        	min_idx = j
    A[i], A[min_idx] = A[min_idx], A[i]

시간복잡도

O(n^2)

공간복잡도

O(n), swap을 주어진 배열 안에서 수행

장점

단순한 알고리즘

제자리 정렬(in-place sorting)

정렬을 위한 비교횟수는 많으나 bubble sort에 비해 실제 교환횟수는 적음

단점

비효율적. 시간 복잡도 O(n^2)

불안정 정렬(unstable sort)

References

https://github.com/GimunLee/tech-refrigerator/blob/master/Algorithm/%EC%84%A0%ED%83%9D%20%EC%A0%95%EB%A0%AC%20(Selection%20Sort).md#%EC%84%A0%ED%83%9D-%EC%A0%95%EB%A0%AC-selection-sort

https://www.geeksforgeeks.org/selection-sort/

 

Selection Sort Algorithm – Data Structure and Algorithm Tutorials - GeeksforGeeks

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

www.geeksforgeeks.org

 

728x90
반응형

'자료구조 알고리즘 > 이론' 카테고리의 다른 글

Insertion Sort  (0) 2023.05.10
Bubble Sort  (0) 2023.05.10
B*Tree  (0) 2023.05.09
B+Tree  (0) 2023.05.09
B-Tree  (0) 2023.05.08
  1. 시간복잡도
  2. 공간복잡도
  3. 장점
  4. 단점
  5. References
'자료구조 알고리즘/이론' 카테고리의 다른 글
  • Insertion Sort
  • Bubble Sort
  • B*Tree
  • B+Tree
내공얌냠
내공얌냠
내공냠냠
내공얌냠
내공냠냠
내공얌냠
전체
오늘
어제
  • 분류 전체보기 (257)
    • 개발 (91)
      • mediapipe (16)
      • insightface (5)
      • JongjuAR (3)
    • 자료구조 알고리즘 (79)
      • 코딩테스트 (64)
      • 이론 (15)
    • 공부 (54)
      • 단행본 (8)
      • 튜토리얼 (19)
      • 논문 (15)
      • 복기 (5)
    • 참여 (5)

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록

공지사항

인기 글

태그

  • 플러터 튜토리얼
  • mediapipe translate
  • speaker adaptation tts
  • mediapipe
  • 음성인식 기초
  • 컴퓨터 비전 책 추천
  • postgresql 재설치
  • flutter 행사 후기
  • python telegrambot
  • 컴퓨터 비전
  • flutter
  • flutter conference
  • flutter 행사
  • google mediapipe
  • 음성인식 튜토리얼
  • 플러터
  • postgresql install in mac
  • 깃 튜토리얼
  • 딥러닝 기반 음성인식 기초
  • git tutorial
  • flutter tutorial
  • ios google places api
  • claude cli 설치
  • 컴퓨터 비전 기초
  • 구글 미디어파이프
  • 머신러닝이란
  • claude cli 사용기
  • claude cli 사용방법
  • 미디어파이프
  • vscode 스프링 설치

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
내공얌냠
Selection Sort
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.