일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- database
- 자바
- java
- array
- Class
- greedy
- Stack
- Binary Tree
- simulation
- geometry
- Number Theory
- dynamic programming
- hash table
- 파이썬
- Method
- Counting
- bit manipulation
- Tree
- 코테
- two pointers
- implement
- sorting
- Data Structure
- Binary Search
- Matrix
- 구현
- string
- SQL
- 코딩테스트
- Math
- Today
- Total
목록탐색 (3)
코린이의 소소한 공부노트
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 location(index low, index high){ index mid; if(low>high) return 0; else{ mid = floor((low+high)/2); if(x==S[mid]) return mid; else if(x 13 -> 18 static int location(int low, int high, int[] S, int x) { int answer; if(low>high) answer = 0; else..
1. Problem - 정렬된 배열에서 x를 찾아보자 2. Input 1) 양수 n 2) 오름차순으로 정렬된 배열 S indexed from 1 to n 3) key x 3. Output 1) x의 위치 2) x가 없다면 0을 반환 4. PseudoCode index binsearch(int n, const keytype S[], keytype x, index location){ index low, high, mid; low = 1; high = n; location = 0; while(low
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..