This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
const int MAX = 1e6; | |
vector<int> v(MAX, 0); | |
void insertionSort(void) | |
{ | |
for (int i = 1; i < v.size(); i++) | |
{ | |
// i 번째까지는 정렬되어있다고 가정 | |
int temp = v[i]; | |
int j; | |
for (j = i - 1; j >= 0 && v[j] > temp; j--) | |
{ | |
v[j + 1] = v[j]; | |
} | |
v[j + 1] = temp; | |
} | |
} |
반응형
'면접 준비' 카테고리의 다른 글
데이터베이스) DBMS 키 정리 (0) | 2020.06.10 |
---|---|
데이터베이스 쿼리 실행 순서 (2) | 2020.06.07 |
선택 정렬(Selection Sort) 구현 (0) | 2019.10.06 |
머지 소트(Merge Sort) STL 없이 구현 (0) | 2019.07.30 |
퀵 소트(Quick Sort) STL 없이 구현 (0) | 2019.07.29 |