Implement the sorting algorithm you came up with in pseudocode with Python Test the sorting algorithm with a list of 10, 100, 1000 random numbers and compare the result using the %time to time your code and submit your results in code comments
In [ ]:
# input: Array A[1...n], of elements in arbitrary order array size n;
# operation: sort the list;
# output:Array A[1...n] of the same elements, but in the increasng order
In [7]:
import random
In [19]:
source_list=[1,5,100,10,2,4]
new_list=[]
while source_list:
minimum = source_list[0]
for i in source_list:
if i < minimum:
minimum=i
new_list.append(minimum)
source_list.remove(minimum)
print(new_list)
In [13]:
def sorting(source_list):
new_list=[]
source_list=[1,5,100,10,2,4]
while source_list:
minimum = source_list[0]
for i in source_list:
if i < minimum:
minimum=i
new_list.append(minimum)
source_list.remove(minimum)
return new_list
In [ ]:
#%time:Time execution of a Python statement or expression.
In [15]:
list_10 = random.sample(range(1, 11),10)
list_100 = random.sample(range(1, 101), 100)
list_1000 = random.sample(range(1, 1001), 1000)
In [16]:
%time sorting(list_10)
Out[16]:
In [17]:
%time sorting(list_100)
Out[17]:
In [18]:
%time sorting(list_1000)
Out[18]:
In [ ]: