python 3.7 code: Exercise 1: Sorting Generate a random array. You can use the following code import
Fantastic news! We've Found the answer you've been seeking!
Question:
python 3.7 code:
Exercise 1: Sorting
Generate a random array. You can use the following code
import numpy as np np.random.seed(1012) DATASIZE = 10000 MAX_VALUE = 1000000000 data = np.random.randint(0, MAX_VALUE, size=DATASIZE)
Write a function that is passed a numpy array. The function walks through the array element-by-element, comparing the current element to the next element. Swap if the next is smaller than the current - sorting these two elements.
Write a second function that calls the function from part 1 nn times, where nn is the number of elements (size) of the array. Pass the same numpy array every time.
Print the result.
Explain to the TA why this sorting function works.
Related Book For
Posted Date: