- #1
wisvuze
- 372
- 1
Homework Statement
hi, I was asked to notice a pattern involving the run times of sorting algorithms.. however, the run time timer program I have keeps giving me different values for the same length lists :| will the pattern/formula be an approximation then? also, I read that the run time should follow n^2 or some kind of quadratic relation.. I just can't see it, the runtime values I'm getting are no way quadratic. could anybody help me?
thanks
Homework Equations
The Attempt at a Solution
here is my selection sort code , it is written in python:
Code:
def swapper(L, i):
larger = i
for e in range(i+1 , len(L)):
if L[e] > L[larger]:
larger = e
return larger
def non_ascending(L):
i = 0
while i != len(L)-1:
larger = swapper(L,i)
L[i], L[larger] = L[larger], L[i]
i += 1