Skip to content

Instantly share code, notes, and snippets.

@mac-r
Created August 14, 2012 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mac-r/3353401 to your computer and use it in GitHub Desktop.
Save mac-r/3353401 to your computer and use it in GitHub Desktop.
Binary Heaps in the Context of Prioritization #2
def heap_extractor(length, n)
random_array = (1..length).to_a.inject(Array.new) {|arr, el| el = rand(1..el); arr << el;}
array = HeapModule.build_max_heap(random_array)
n.times do
HeapModule.extract_maximum(array)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment