Advertisement
EXTREMEXPLOIT

Recursive QuickSort Algorithm

May 18th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. def QuickSort(Array):
  2.     if len(Array) == 0:
  3.         return []
  4.     RightArray = []
  5.     LeftArray = []
  6.     Pivot = Array[0]
  7.     n = 1
  8.     while n < len(Array):
  9.         if Array[n] >= Pivot:
  10.             RightArray.append(Array[n])
  11.         else:
  12.             LeftArray.append(Array[n])
  13.         n += 1
  14.     return QuickSort(LeftArray) + [Pivot] + QuickSort(RightArray)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement