-
자료구조 - 이진탐색 (Binary Search)인공 지능 개념 2024. 9. 22. 15:14
이진탐색 (Binary Search)
1. 정렬된 배열에서 원하는 값을 찾는 알고리즘
a = [1,3,7,10,17,21,35]
값을 찾을때
1. 중앙값을 선택한다.
2. 찾는값이 중앙값보다 작으면
배열의 왼쪽부분에서 다시 찾는다.
3. 찾는값이 중앙값보다 크면 배열의 오른쪽 부분에서 다시 찾는다.
4. 찾는 값이 중앙값과 같으면 값을 찾았으므로 해당 index를 반환
'인공 지능 개념' 카테고리의 다른 글
자료구조 - AVR 트리 (0) 2024.09.22 자료구조 - 이진 탐색트리 - 중요 (0) 2024.09.22 자료구조 - 트리탐색 (0) 2024.09.22 자료구조 - Heap (2) (0) 2024.09.21 자료구조 - Heap (0) 2024.09.20