정렬 (Sorting Algorithm)

Andrew Kyung·2022년 3월 13일

알고리즘

목록 보기
1/1

Sorting Algorithm : An algorithm that puts elements of a list into an order. - Wikipedia-

1. Bubble Sort

Example

Code

Problem

2. Insertion Sort

Example

Code

int arr[MAX_NUM];

void InsertionSort(int num){
    for(int i=1;i<num;++i){
        int key = arr[i];
        int j = i-1;

        while(j >=0 && key < arr[j]){
            arr[j+1] = arr[j];
            j--;
        }

        arr[j+1] = key;
    }
}

Problem : BOJ_2750

3. Merge Sort

Example

Code

Problem

4. Quick Sort

Example

Code

Problem

0개의 댓글