Question: 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
My pseudocode:
1. Have a list of random numbers
2. Create a new empty list
3. Find the smallest number of the first list and put it in the empty list
4. Remove the smallest number from the old list
5. Do it again until we run out of numbers using a for loop
In [1]:
import random
In [30]:
list_of_ten_numbers = random.sample(range(1,1000000), 10)
new_ten_list = []
for item in range(len(list_of_ten_numbers)):
smallest_number = min(list_of_ten_numbers)
new_ten_list.append(smallest_number)
list_of_ten_numbers.remove(smallest_number)
new_ten_list
%time
In [29]:
list_of_hundred_numbers = random.sample(range(1,1000000), 100)
new_hundred_list = []
for item in range(len(list_of_hundred_numbers)):
smallest_number = min(list_of_hundred_numbers)
new_hundred_list.append(smallest_number)
list_of_hundred_numbers.remove(smallest_number)
new_hundred_list
%time
In [32]:
list_of_thou_numbers = random.sample(range(1,1000000), 1000)
new_thou_list = []
for item in range(len(list_of_thou_numbers)):
smallest_number = min(list_of_thou_numbers)
new_thou_list.append(smallest_number)
list_of_thou_numbers.remove(smallest_number)
new_thou_list
%time
In [ ]: