psuedocoded some stuff while multitasking
This commit is contained in:
parent
3943d0c8f2
commit
30a10892eb
1 changed files with 9 additions and 10 deletions
|
@ -1,7 +1,6 @@
|
||||||
module Algorithms
|
module Algorithms
|
||||||
class Sorting
|
class Sorting
|
||||||
def selection(a)
|
def selection(array)
|
||||||
# a is an Array
|
|
||||||
# from: https://www.tutorialspoint.com/data_structures_algorithms/selection_sort_algorithm.htm
|
# from: https://www.tutorialspoint.com/data_structures_algorithms/selection_sort_algorithm.htm
|
||||||
# Step 1 − Set MIN to location
|
# Step 1 − Set MIN to location
|
||||||
# Step 2 − Search the minimum element in the list
|
# Step 2 − Search the minimum element in the list
|
||||||
|
@ -9,16 +8,16 @@ module Algorithms
|
||||||
# Step 4 − Increment MIN to point to next element
|
# Step 4 − Increment MIN to point to next element
|
||||||
# Step 5 − Repeat until list is sorted
|
# Step 5 − Repeat until list is sorted
|
||||||
|
|
||||||
counter = 0
|
# set a max
|
||||||
max = a.length
|
max = array.max
|
||||||
|
|
||||||
a.map do |item|
|
# set the index of the min and use it with pop to make new array
|
||||||
#binding.pry
|
index_of_min = array.index(array.min)
|
||||||
counter += 1
|
almost_sorted_array = array.pop(index_of_min)
|
||||||
end
|
|
||||||
|
incremented_index = array[index_of_min + 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def insertion
|
def insertion
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue