diff --git a/BubbleSort.python b/BubbleSort.py similarity index 100% rename from BubbleSort.python rename to BubbleSort.py diff --git a/InsertionSort.python b/InsertionSort.py similarity index 99% rename from InsertionSort.python rename to InsertionSort.py index 451f6e905..e0417a755 100644 --- a/InsertionSort.python +++ b/InsertionSort.py @@ -1,5 +1,3 @@ - - array=[]; # input diff --git a/SelectionSort.py b/SelectionSort.py new file mode 100644 index 000000000..89b6977cb --- /dev/null +++ b/SelectionSort.py @@ -0,0 +1,14 @@ +print ("Enter numbers seprated by comma ") +def selectionsort( aList ): + for i in range( len( aList ) ): + least = i + for k in range( i + 1 , len( aList ) ): + if aList[k] < aList[least]: + least = k + + swap( aList, least, i ) + +def swap( A, x, y ): + tmp = A[x] + A[x] = A[y] + A[y] = tmp