1. 알고리즘
- 탐색시간은 O(logN)이다.
- 정렬 알고리즘은 다음과 같다.
left = 0
rigth = n - 1
while left < right:
mid = (left + right) / 2
if arr[mid] < target:
left = mid + 1
else:
right = mid
if (left == right) and (arr[left] == x):
found = True
foundpos = left
else:
found = False
'Computer Science > Data Structure' 카테고리의 다른 글
Heap, PQ (0) | 2022.06.11 |
---|---|
Map and Hash (0) | 2022.04.28 |
Amortized Analysis(분할 상환 분석) (0) | 2022.04.14 |
asymptotic notation(점근 표기법) (0) | 2022.04.13 |