Oh My Algorithm
Algorithm Guidecomplexity: O(log n)

이진 탐색 (Binary Search)

정렬된 배열에서 중간값을 반복적으로 비교하여 탐색 범위를 반으로 줄여가는 매우 빠르고 뛰어난 성능의 검색 알고리즘입니다. 매 반복마다 후보 공간을 절반으로 축소해 로그 스케일의 비교 횟수만으로 값을 찾아냅니다.

01 Explore How It Works

Interactive Step-by-Step
Binary Search
3412565234567

이진 탐색 시작. 정렬된 배열을 결정 트리로 표현하면 각 노드가 해당 반복의 mid 원소가 됩니다.

Logic Node1 / 7

02 Understand It Simply

For Everyone
🔑Analogy

사전을 펼쳐 중간을 보고 앞·뒤 절반으로 좁혀가는 것.

💡In Plain Words

정렬된 배열에서 중간값과 비교해 탐색 범위를 매번 절반으로 줄입니다.

O(log n)으로 매우 빨라요.

📍Where It's Used
  • 정렬된 데이터 검색
  • 경계값 찾기

03 Python Implementation

A clean, readable reference implementation of the core logic of 이진 탐색 (Binary Search).

core_implementation.py
def binary_search(arr, target):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            low = mid + 1
        else:
            high = mid - 1
    return -1

04 Frequently Asked Questions

FAQ
What is 이진 탐색 (Binary Search)?+

정렬된 배열에서 중간값을 반복적으로 비교하여 탐색 범위를 반으로 줄여가는 매우 빠르고 뛰어난 성능의 검색 알고리즘입니다. 매 반복마다 후보 공간을 절반으로 축소해 로그 스케일의 비교 횟수만으로 값을 찾아냅니다.

What is the time complexity of 이진 탐색 (Binary Search)?+

The time complexity of 이진 탐색 (Binary Search) is O(log n). Follow the step-by-step visualization to see exactly why.

Where is 이진 탐색 (Binary Search) used?+

정렬된 데이터 검색, 경계값 찾기.

What's a simple analogy for 이진 탐색 (Binary Search)?+

사전을 펼쳐 중간을 보고 앞·뒤 절반으로 좁혀가는 것.

Guide Progress0%