Quicksort mit Python

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Quicksort mit Python

by Anonymous » 17 Mar 2025, 15:15

Ich bin total neu in Python und ich versuche, Quicksort darin zu implementieren.
Könnte jemand mir bitte helfen, meinen Code zu vervollständigen?

Code: Select all

def sort(array=[12,4,5,6,7,3,1,15]):
less = []
equal = []
greater = []

if len(array) > 1:
pivot = array[0]
for x in array:
if x < pivot:
less.append(x)
if x == pivot:
equal.append(x)
if x > pivot:
greater.append(x)
sort(less)
sort(pivot)
sort(greater)

Top