File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ function selectionSort(arr) {
53
53
```
54
54
55
55
``` python
56
- def selection_sort (list ):
56
+ def selection_sort_out_of_place (list ):
57
57
sorted_list = []
58
58
59
59
while len (list ) > 0 :
@@ -65,6 +65,24 @@ def selection_sort(list):
65
65
return sorted_list
66
66
```
67
67
68
+ ``` python
69
+ def selection_sort_in_place (list ):
70
+ for i in range (len (list )):
71
+ min_element = list[i]
72
+ min_element_index = i
73
+
74
+ for j in range (i + 1 , len (list )):
75
+ if list[j] < min_element:
76
+ min_element = list[j]
77
+ min_element_index = j
78
+
79
+ temp_element_0 = list[i]
80
+ list[i] = min_element
81
+ list[min_element_index] = temp_element_0
82
+
83
+ return list
84
+ ```
85
+
68
86
Use the language of your choosing. We've included starter files for some
69
87
languages where you can pseudocode, explain your solution and code.
70
88
You can’t perform that action at this time.
0 commit comments