Skip to content

Commit

Permalink
Add Heap sort
Browse files Browse the repository at this point in the history
  • Loading branch information
azusa152 committed Feb 16, 2020
1 parent 3a9136f commit b2ff7f4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sorting/HeapSort.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative '../Data Structure/Heap.rb'
require 'benchmark'
input_array = Array.new(100){rand(1...100)}

def heap_sort input_array
heap= Heap.new(input_array)
output_array = []
while heap.size!=0
output_array.push heap.peak
heap.pop
end
#print output_array
end


time = Benchmark.measure {
heap_sort input_array
}
puts time.real

0 comments on commit b2ff7f4

Please sign in to comment.