Binary search
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Binary search
The array is sorted. Return the index of target, or -1 if it isn't there. Binary search halves the range each step: check the middle element, then keep looking in just the left or right half. Far faster than scanning every element.
한국어
이진 검색
이 배열은 정렬되어 있습니다. target의 인덱스를 반환하고, 존재하지 않으면 -1을 반환하세요. 이진 탐색은 매 단계마다 범위를 절반으로 줄입니다: 중간 요소를 확인한 후 왼쪽 또는 오른쪽 절반 중 하나만 계속 탐색합니다. 모든 요소를 스캔하는 것보다 훨씬 빠릅니다.
Complete binarySearch(int[] a, int target) for a sorted array a: return the index of target, or -1 if absent. Use binary search.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.