I am trying to write a section of a larger program which will generate a list of random integers. the first randomly generated list should have X elements, and then generate another list of random integers with X + Y elements, and so on, sequentially adding Y to the number of elements until I get to a specified point. Each generated list will also be sorted using the selection sort method. I am using several different sort methods (selection, bubble, merge, quick, radix...) to calculate the execution time of each method for increasing input sizes. As far as the selection sort portion, I have this so far but the output I'm getting is 100 lists of 100 numbers. Clearly I'm still pretty new to Python.
Hoping for a breakthrough, thanks!
import time
import random
start_timeSelection = time.clock()
lst = []
count = 100
def selectionSort(lst):
count = 100
lst = [int(999*random.random()) for i in range(count)]
for i in range(len(lst) - 1):
currentMin = lst[i]
currentMinIndex = i
for j in range(i + 1, len(lst)):
if currentMin > lst[j]:
currentMin, currentMinIndex = lst[j], j
if currentMinIndex != i:
lst[currentMinIndex], lst[i] = lst[i], currentMin
print(lst)
while count < 300:
count += 100
selectionSort(lst)
s = (time.clock() - start_timeSelection)
print("Selection Sort execution time is: ", s, "seconds")