김호쭈
DevForYou
김호쭈
전체 방문자
오늘
어제
  • 분류 전체보기 (321)
    • • 데이터베이스(DB) (9)
      • __SQL__ (9)
    • •알고리즘(Algorithm ) (117)
      • 문제풀이 (99)
      • 스터디 (14)
      • 알고리즘 팁 (4)
    • •Compter Science (57)
      • Operating System (25)
      • Computer Network (1)
      • Computer Vision (16)
      • Artificial Intelligence (14)
      • Software Technology (1)
    • • 독서 (36)
      • Design Pattern (24)
      • 객체지향의 사실과 오해 (1)
      • Object Oriented Software En.. (11)
    • • 개발 (26)
      • React (3)
      • node.js (6)
      • Django (11)
      • Spring boot (6)
    • • 개발Tip (4)
      • GitHub (0)
    • •프로젝트 (2)
      • 물물 (2)
    • •App (54)
      • 안드로이드 with Kotlin (50)
      • 코틀린(Kotiln) (4)
    • •회고 (8)
    • •취준일기 (3)
    • • 기타 (2)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 원격저장소
  • local저장소
  • Remote저장소
  • GitHubDesktop
  • ㄱ
  • 로컬저장소
  • 깃허브데스크탑
  • KMU_WINK

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
김호쭈

DevForYou

•알고리즘(Algorithm )/스터디

[알고리즘] 선택 정렬 파이썬

2022. 7. 22. 18:37

# 코드

import random

def selection_sort(data):
  size = len(data)
  for target in range(size):
    min_index = target
    for index in range(target + 1, size):
      if (data[min_index] > data[index]):
        min_index = index
    #swap
    temp = data[min_index]
    data[min_index] = data[target]
    data[target] = temp


if __name__ == '__main__':
  input = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
  sample_list = random.sample(range(10),10)

  # test
  print(f"before {sample_list}")
  selection_sort(sample_list)
  print(f"sorted {sample_list}")

 

# 시간복잡도 

O(n^2)

저작자표시 (새창열림)

'•알고리즘(Algorithm ) > 스터디' 카테고리의 다른 글

[알고리즘] 병합정렬(merge-sort) 파이썬  (0) 2022.07.24
[알고리즘] 재귀함수 파이썬, 회문검사  (0) 2022.07.23
[알고리즘] 삽입정렬 파이썬  (0) 2022.07.22
[알고리즘] 버블정렬 파이썬  (0) 2022.07.22
[정렬] 버블정렬(Bubble Sort) 알고리즘  (0) 2021.05.21
    '•알고리즘(Algorithm )/스터디' 카테고리의 다른 글
    • [알고리즘] 병합정렬(merge-sort) 파이썬
    • [알고리즘] 재귀함수 파이썬, 회문검사
    • [알고리즘] 삽입정렬 파이썬
    • [알고리즘] 버블정렬 파이썬
    김호쭈
    김호쭈
    공부하고 정리하고 기록하기

    티스토리툴바