Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -0,0 +1,8 @@
|
|||
from random import *
|
||||
|
||||
def qSort(a):
|
||||
if len(a) <= 1:
|
||||
return a
|
||||
else:
|
||||
q = choice(a)
|
||||
return qSort([elem for elem in a if elem < q]) + [q] * a.count(q) + qSort([elem for elem in a if elem > q])
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
def quickSort(a):
|
||||
if len(a) <= 1:
|
||||
return a
|
||||
else:
|
||||
less = []
|
||||
more = []
|
||||
pivot = choice(a)
|
||||
for i in a:
|
||||
if i < pivot:
|
||||
less.append(i)
|
||||
if i > pivot:
|
||||
more.append(i)
|
||||
less = quickSort(less)
|
||||
more = quickSort(more)
|
||||
return less + [pivot] * a.count(pivot) + more
|
||||
Loading…
Add table
Add a link
Reference in a new issue