I'm currently doing an algorithms course and implemented this version of the quicksort algorithm. I would like to know if it is an efficient implementation. I've seen a couple others where there is a partition function that partitions the list is that a superior method to what I did?
def quickSort(aList):
first = []
second = []
size = len(aList)
if size ==0:
return []
elif size == 1:
return aList
elif size ==2:
if(aList[1]<aList[0]):
return list([aList[1],aList[0]])
else:
return aList
else:
key = aList[0]
for i in range(1,size):
if aList[i]<key:
first.append(aList[i])
else:
second.append(aList[i])
first.append(key)
return quickSort(first) + quickSort(second)