Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5fd4d3

Browse files
added -selSort
1 parent e66d515 commit e5fd4d3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎selection-sort/select.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Sorting Arrays using Selection Sort Method
2+
3+
def selSort(arr):
4+
n = len(arr)
5+
for i in range(n):
6+
minId = i
7+
for j in range(i+1, n):
8+
if arr[j] < arr[minId]:
9+
minId = j
10+
arr[i], arr[minId] = arr[minId], arr[i]
11+
12+
arr = [23, 56, 9, 103, 77]
13+
selSort(arr)
14+
print("Sorted array is: ", arr)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /