Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created May 15, 2021 17:30
Show Gist options
  • Save Park-Developer/6572365dfe1bc154a0ef51dce093d518 to your computer and use it in GitHub Desktop.
Save Park-Developer/6572365dfe1bc154a0ef51dce093d518 to your computer and use it in GitHub Desktop.
binary search using recursion
# 재귀함수
def binary_search_rec(seq, target, low,high):
if low > high:
return None
mid = (low+high)//2
if target == seq[mid]:
return mid
elif target<seq[mid]:
return binary_search_rec(seq, target, low,mid-1)
else:
return binary_search_rec(seq, target, mid+1,high)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment