본문 바로가기

Just Fighting

검색하기
Just Fighting
프로필사진 yennle

  • 분류 전체보기 (162)
    • Web (8)
      • 프론트엔드 (3)
      • 백엔드 (4)
    • Algorithm (39)
      • 코딩테스트 연습 (38)
      • 개념 정리 (1)
    • ML & DL (13)
    • Big Data (13)
    • Python (29)
    • SAS (12)
    • ETC (3)
Guestbook
«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록Algorithm/개념 정리 (1)

Just Fighting

[Python] 이진 탐색(Binary Search)

N개의 정렬된 숫자가 있으면 숫자의 개수를 반씩 줄여나가면서 원하는 숫자를 찾는 탐색 방법이다. 이진 탐색의 시간 복잡도 : O(logN) target의 인덱스를 찾아라. def binarySearch(data, target): start = 0 end = len(data)-1 while start target : end = mid - 1 else : return mid return -1 내가 찾는 수가 리스트에 없을 경우 end의 초기값과 while이 실행되는 조건, whlie문 안에 if-else문이 달라진다. target보다 크거나 같은 수가 시작되는 인덱스를 찾아라. def binarySearch_lower(data, target): start = 0 end = len(data) while sta..

Algorithm/개념 정리 2022. 1. 26. 20:37
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바