mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-07 03:07:46 +08:00
Optimised for loop iteration
This commit is contained in:
@ -31,7 +31,7 @@ def selection_sort(collection):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
length = len(collection)
|
length = len(collection)
|
||||||
for i in range(length):
|
for i in range(length - 1):
|
||||||
least = i
|
least = i
|
||||||
for k in range(i + 1, length):
|
for k in range(i + 1, length):
|
||||||
if collection[k] < collection[least]:
|
if collection[k] < collection[least]:
|
||||||
|
Reference in New Issue
Block a user