parent
fa3f0e084f
commit
ccc78a79a4
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
1. [Bubble Sort](python/bubble-sort.py)
|
1. [Bubble Sort](python/bubble-sort.py)
|
||||||
2. [Insertion Sort](python/insertion-sort.py)
|
2. [Insertion Sort](python/insertion-sort.py)
|
||||||
2. [Selection Sort](python/selection-sort.py)
|
3. [Selection Sort](python/selection-sort.py)
|
||||||
|
4. [Quick Sort](python/quick-sort.py)
|
||||||
|
|
||||||
### Java
|
### Java
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
def quickSort(arr):
|
||||||
|
n = len(arr)
|
||||||
|
if n == 1 or n == 0:
|
||||||
|
return arr
|
||||||
|
pi = 0
|
||||||
|
left = [arr[i] for i in range(n) if arr[i] <= arr[pi] and i != pi]
|
||||||
|
right = [arr[i] for i in range(n) if arr[i] > arr[pi]]
|
||||||
|
return quickSort(left) + [arr[pi]] + quickSort(right)
|
||||||
|
|
||||||
|
|
||||||
|
arr = [10, 1, 6, 256, 2, 53, 235, 53, 1, 7, 23]
|
||||||
|
print("Sorted Array:", quickSort(arr))
|
Loading…
Reference in New Issue