Skip to content

Commit

Permalink
Create selection-sort.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mananjain31 authored Oct 21, 2022
1 parent 5bc85d2 commit 1193d39
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions selection-sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Selection Sort

def selectionSort(arr):
n = len(arr)
for i in range(n):
mini = i
for j in range(i,n):
if arr[j] < arr[mini]:
mini = kj
arr[i], arr[mini] = arr[mini], arr[i]

arr = [1,2,43,421,3,1,2,32,1,9,23,8]
selectionSort(arr)
print(arr)

0 comments on commit 1193d39

Please sign in to comment.