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 and has n elements. Return the index of target, or -1 if it isn't present. Keep lo and hi bounds, check the middle each step, and discard the half that can't contain the target.
한국어
이진 검색
이 배열은 정렬되어 있으며 n개의 요소를 가집니다. target의 인덱스를 반환하거나, 존재하지 않으면 -1을 반환합니다. lo과 hi의 경계를 유지하고, 각 단계마다 중간값을 확인하며 타겟을 포함할 수 없는 절반을 버립니다.
Complete int binary_search(const int *a, int n, int target) for a sorted array of length n: return the index of target, or -1 if absent.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.