changed to only single for loop in quick for to reduce time complexity. thanks to mr. lalit hinduja

This commit is contained in:
K 2023-12-11 09:47:09 +05:30
parent d8ad39d234
commit 3a6ad7c77f
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -12,16 +12,14 @@ def quickSort(arr):
'''
## ALTERNATIVE WAY OF WRITING THE UPPER 3 LINES (for easy understanding)
left = [] # Empty list to store left part
middle = [] # Empty list to store middle element
right = [] # Empty list to store right part
for i in arr:
if (i < pivot):
left.append(i)
middle = [] # Empty list to store middle element
for i in arr:
if (i == pivot):
elif (i == pivot):
middle.append(i)
right = [] # Empty list to store right part
for i in arr:
if (i > pivot):
else:
right.append(i)
'''