Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

linear search python

#this is really basic, but it'll do
Array = [1,2,3,4,5,6,7,8] #example array
def LinearSearch(Array, SearchVal): #SearchVal= value you are looking for
	for i in range(len(Array)):
      if Array[i]== SearchVal:
        return True
    return False
 #once it has looped through all of the array and hasn't found
 #the search value, it will return False.        
 
PREVIOUS NEXT
Tagged: #linear #search #python
ADD COMMENT
Topic
Name
3+2 =