changed to only single for loop in quick for to reduce time complexity. thanks to mr. lalit hinduja
This commit is contained in:
parent
d8ad39d234
commit
3a6ad7c77f
@ -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)
|
||||
'''
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user