crneoa
Last Updated: January 04, 2018
·
574
· fatima

Bubble stor in ruby

def bubble_sort(array)
n = array.length
swapped = true
while swapped do
swapped = false
(n - 1).times do |i|
if array[i] > array[i + 1]
array[i], array[i + 1] = array[i + 1], array[i]
swapped = true
end
end
end
array
end

Say Thanks
Respond

1 Response
Add your response

29545

Recommended

about 1 month ago ·