Ruby
Latest commit fc6ddf9 Jun 2, 2010 @evansenter Merge branch 'master' of github.com:evansenter/f_heap
Conflicts:
	README
Permalink
Failed to load latest commit information.
lib
test Fibonacci Heap implementation in Ruby Jun 1, 2010
MIT-LICENSE
README
Rakefile First commit. May 31, 2010
init.rb
install.rb
uninstall.rb

README

FHeap
=====

This is an implementation of the Fibonacci Heap data structure in Ruby. The Fibonacci Heap is a collection of trees that satisfy the minimum heap property (that is to say, each child node has a value >= its parent's value), which elicits the trait of having a better amortized runtime than a binomial heap.

Example
=======

irb(main):002:0> heap = FHeap.new
=> #<FHeap:0x10164d0c8 @trees=[], @min_node=nil>

irb(main):003:0> heap.insert!(9)
irb(main):004:0> heap.insert!(7)
irb(main):005:0> heap.insert!(8)
irb(main):006:0> heap.insert!(6)
irb(main):007:0> heap.insert!(5)
irb(main):008:0> heap.insert!(3)
irb(main):009:0> heap.insert!(4)
irb(main):010:0> heap.insert!(2)
irb(main):011:0> heap.insert!(1)
irb(main):012:0> heap.insert!(0)

irb(main):013:0> heap.extract_minimum!.value
=> 0
irb(main):014:0> heap.extract_minimum!.value
=> 1
irb(main):015:0> heap.extract_minimum!.value
=> 2
irb(main):016:0> heap.extract_minimum!.value
=> 3
irb(main):017:0> heap.extract_minimum!.value
=> 4
irb(main):018:0> heap.extract_minimum!.value
=> 5
irb(main):019:0> heap.extract_minimum!.value
=> 6
irb(main):020:0> heap.extract_minimum!.value
=> 7
irb(main):021:0> heap.extract_minimum!.value
=> 8
irb(main):022:0> heap.extract_minimum!.value
=> 9
irb(main):023:0> heap.extract_minimum!
=> nil

Copyright (c) 2010 Evan Senter, released under the MIT license