You need to complete this code and ADD to it in order to find the
position of a key in the list:
(it MUST be using this existing code in python and MUST use
numpy)
PROVIDE CODE AND SCREENSHOT OF THE MATCHING
OUTPUT SHOW BELOW
def search1DList (theList, number):
return "Not found ",k+1
# Use the main testdriver
import time
import numpy as np
import random
np.random.seed(42)
theSize=1000000000 # generate one billion numbers
randomNumber=np.random.randint(0,1000000, size=theSize)
print(randomNumber)
print(" size of the list:", len(randomNumber))
print(randomNumber[theSize-1]) # print the last int in the list
start-time.time
answer, pos=search1DList(randomNumber, -5) // search for a non- existent key \rightarrow worst case
finish-time.time()
print (answer," at position", pos)
print ("time is: ", str(finish-start), " seconds")
THE OUTPUT MUST LOOK LIKE THIS:
[121958 671155 131932 ... 923606 556789 831779]
size of the list : 1000000000
831779
Not found at position 1000000000
time is: 154.58296728134155 seconds