Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- Binary Search
- 파이썬
- 코테
- dynamic programming
- sorting
- greedy
- Stack
- string
- 코딩테스트
- Class
- implement
- 구현
- database
- bit manipulation
- Data Structure
- Math
- hash table
- SQL
- array
- two pointers
- simulation
- Matrix
- Counting
- Tree
- java
- 자바
- Method
- Number Theory
- geometry
- Binary Tree
Archives
- Today
- Total
목록O(n lg n) (1)
코린이의 소소한 공부노트
Merge Sort (recursive)
1. Problem - n개의 key를 오름차순으로 정렬하자 2. Input 1) 양수 n 2) 배열 S indexed from 1 to n 3. Output 1) 오름차순으로 정렬된 배열 S 4. PseudoCode void mergesort(int n, keytype[] S){ if(n>1){ const int h = n/2, m = n-h; keytype U[1..h], V[1..m]; copy S[1]~S[h] to U[1]~U[h]; copy S[h+1]~S[n] to V[1]~V[m]; mergesort(h,U); mergesort(m,V); merge(h,m,U,V,S); } } // 정렬된 배열 U와 V의 요소를 합해서 정렬된 S를 만든다. void merge(int h, int m, co..
Back-End/Algorithm
2023. 2. 23. 23:56