started a little bit of selection sorting algorithm

This commit is contained in:
booboy 2019-05-04 20:56:36 -05:00
parent 9121bccc68
commit 7c95d2a96c

View file

@ -1,11 +1,27 @@
module Algorithms
class Sorting
def selection(a, n)
end
def selection(a)
# a is an Array
# from: https://www.tutorialspoint.com/data_structures_algorithms/selection_sort_algorithm.htm
# Step 1 Set MIN to location
# Step 2 Search the minimum element in the list
# Step 3 Swap with value at location MIN
# Step 4 Increment MIN to point to next element
# Step 5 Repeat until list is sorted
def bubble
end
a.each_with_index do |value, index|
# set current element as minimum
current_element = a[index]
next_element = a[index + 1]
if next_element.nil? == false && current_element > next_element
puts "Current Element: #{current_element}"
puts "Next Element: #{next_element}"
end
end
def insertion
end