Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STL for Fibonacci Heap?

where is the Fibonacci Heap in STL ? and if STL do not implement Fibonacci Heap what is the best practice to implement it using existing algorithms and containers in STL ?

like image 441
amin Avatar asked Jan 02 '13 07:01

amin


2 Answers

boost has an implementation of it. Hope that helps. There doesn't seem to be one in the STL. Here's an example:

 for(int n=0;n<40;++n){
    std::cout<<"F("<<n<<")="<<fibonacci(n)<<std::endl;
  }
like image 148
hd1 Avatar answered Oct 15 '22 22:10

hd1


Even though it is not stated explicitly as a Fibonacci heap, the STL implements a priority_queue which has the same complexity and the same api and behavior as a Fibonacci heap (and may actually be a Fibonacci heap in disguise)

https://en.cppreference.com/w/cpp/container/priority_queue

like image 33
hl037_ Avatar answered Oct 15 '22 23:10

hl037_