FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms-python/algorithms/sort/selection_sort.py at master · Mu-L/algorithms-python · GitHub
Mu-L
/
algorithms-python
Public
forked from
keon/algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms-python
/
algorithms
/
sort
/
selection_sort.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (18 loc) · 609 Bytes
Breadcrumbs
algorithms-python
/
algorithms
/
sort
/
selection_sort.py
Copy path
File metadata and controls
23 lines (18 loc) · 609 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def
selection_sort
(
arr
,
simulation
=
False
):
""" Selection Sort
Complexity: O(n^2)
"""
iteration
=
0
if
simulation
:
print
(
"iteration"
,
iteration
,
":"
,
*
arr
)
for
i
in
range
(
len
(
arr
)):
minimum
=
i
for
j
in
range
(
i
+
1
,
len
(
arr
)):
# "Select" the correct value
if
arr
[
j
]
<
arr
[
minimum
]:
minimum
=
j
arr
[
minimum
],
arr
[
i
]
=
arr
[
i
],
arr
[
minimum
]
if
simulation
:
iteration
=
iteration
+
1
print
(
"iteration"
,
iteration
,
":"
,
*
arr
)
return
arr
Back
|
FazBrowse Home
|
New Git URL