일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- Math
- string
- bit manipulation
- SQL
- Number Theory
- greedy
- Counting
- Method
- Tree
- 파이썬
- hash table
- geometry
- implement
- Stack
- 자바
- array
- two pointers
- 코테
- simulation
- dynamic programming
- Data Structure
- Matrix
- Binary Search
- Binary Tree
- database
- 구현
- 코딩테스트
- Class
- java
- sorting
- Today
- Total
목록o(n) (2)
코린이의 소소한 공부노트
1. Problem - 배열의 요소를 오름차순으로 정렬해보자. - 정렬할 데이터의 범위를 알고 있다면 데이터의 개수를 세어서 정렬할 수 있다. 2. Input 1) int[] arr 3. Output 1) arr를 오름차순으로 정렬한 결과 4. Example // 예시: 5 5 4 4 3 3 3 2 2 1 // 배열의 앞에서부터 읽어가며 카운팅을 한다. // 5 -> count[5]++; // 5 -> count[5]++; // 4 -> count[4]++; // ... // 1 -> count[1]++; // count = [0, 1, 2, 3, 2, 2] // 이것을 바탕으로 정렬된 결과를 출력하면 // 1 2 2 3 3 3 4 4 5 5 5. Code int[] arr = {1,2,3,4,5,5,4..
1. Problem - n개의 요소가 담긴 배열 S에서 x를 찾아보자 2. Input 1) 양수 n 2) 배열 S indexed from 1 to n 3) key x 3. Output 1) x의 위치 2) S에 x가 없다면 0을 반환 4. PseudoCode index seqsearch(int n, const keytype[] S, keytype x, index location){ location = 1; while(locationn) location = 0; return location; } 5. Example class Test { public static void main(String[] args){ int[] arr = {5, 9, 3, 10, 6, 2, 1}; int a = 6; int inde..