본문 바로가기

알고리즘/정렬4

[알고리즘] 삽입 정렬(Insertion Sort) in Python 카드 놀이를 할 때 나도 모르게 카드를 정렬한 적이 있는가? 그때 어떠한 방식으로 정렬을 했는지 생각해 보자. 정렬 알고리즘에서 세 번째로 배워 볼 것은 바로 삽입 정렬이다. 삽입 정렬이 어떻게 동작하는지 알아 보고 실제 코드로 구현해 보자. 📌 정의 Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Values from the unsorted part are picked and placed at the correct position in .. 2023. 3. 13.
[알고리즘] 선택 정렬(Selection Sort) in Python 정렬 알고리즘에서 두 번째로 배워 볼 것은 선택 정렬이다. 선택 정렬은 어떻게 동작하는지 알아 보고 실제 코드로 구현해 보자. 📌 정의 Selection sort is a simple and efficient sorting algorithm that works by repeatedly selecting the smallest (or largest) element from the unsorted portion of the list and moving it to the sorted portion of the list. 선택 정렬은 리스트(배열)의 정렬되지 않은 부분에서 가장 작은(혹은 가장 큰) 요소를 반복적으로 선택하여, 리스트의 정렬된 부분으로 옮기는 방식의 간단하고 효율적인 정렬 알고리즘이다. Sele.. 2023. 3. 12.
[알고리즘] 버블 정렬(Bubble Sort) in Python 정렬 알고리즘 중에서 가장 직관적이고 간단한 버블 정렬에 대해 알아보자. 그리고 버블 정렬이 어떻게 동작하는지 배우고 이를 코드로 구현해 보자. 📌 정의 Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the input list element by element, comparing the current element with the one after it, swapping their values if needed. 가라앉는 정렬이라고도 불리는 버블(거품) 정렬은, 입력된 리스트의 요소 별로, 현재 요소를 바로 다음의 요소와 비교를 하는데, 필요에 따라 서.. 2023. 3. 10.
[알고리즘] 정렬 알고리즘(Sorting Algorithms) 개요 📌 서문 알고리즘 강의에서, 대개 정렬 알고리즘을 가장 먼저 배운다. 정렬 알고리즘은 무엇이고, 왜 공부하는 것이며 강의 초반에 배우는 것일까? 📌 정의 In computer science, a sorting algorithm is an algorithm that puts elements of a list into an order. 컴퓨터 과학에서, 정렬 알고리즘은 하나의 리스트(배열)의 요소들을 일정한 순서에 맞게 분류하는 것을 의미한다. Sorting algorithm - Wikipedia 📌 학습 목적 1. 정렬 알고리즘은 주어진 데이터를 처리하는 알고리즘의 기초가 되는 문제 중 하나이다. 일상에서 주어진 데이터의 집합을 어떠한 규칙으로 나열하는 것(알파벳순, 내림차순, 오름차순 등)을 쉽게 접할 .. 2023. 3. 9.
반응형