Can someone help me with this .I am having so many difficulties in it .
I am not fully understanding how to proceed with it .
Setup Linear Search
Write a functiona that takes a list (L) and a number of times to search through it (N), and executes teh following instructions:
Compute the min and max of L
Loop through N times:
Generate a random number between min and max values of L
Use the list index() method to find the randome number
In [ ]:
I am not fully understanding how to proceed with it .
Setup Linear Search
Write a functiona that takes a list (L) and a number of times to search through it (N), and executes teh following instructions:
Compute the min and max of L
Loop through N times:
Generate a random number between min and max values of L
Use the list index() method to find the randome number
In [ ]:
import random def linear_search_tester(L, N): #Put your code here.... # random.randrange(0,size) return None X = [1,2,3,4,5,6,7,8,9,10,20,30,40,50,100]I am trying to use this code. BUt how can i get the max and min in it .
def linear( target, list ): """ returns the position of target,if not found returns -1""" position = 0 if len(list)==0: return -1 else: while position <= (len(list)+1): if target == list[position]: return position position += 1 return -1