Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

binary search in python

def binary_search(group, suspect):
  group.sort()
  midpoint = len(group)//2
  while(True):
    if(group[midpoint] == suspect):
      return midpoint
    if(suspect > group[midpoint]):
            group = group[midpoint]
    if(suspect < group[midpoint]):
      group = group[0: midpoint]
    midpoint = (len(group)//2)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #binary #search #python
ADD COMMENT
Topic
Name
8+1 =