Question

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 ?

Was it helpful?

Solution

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;
  }

OTHER TIPS

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

no, there is no guaranteed fibonacci heap in the standard library

for an example of implementing a custom allocation scheme in C++, see the small object allocator in the Loki library


EDIT: sorry, i was thinking of the fibonacci buddy system for implementing a dynamic memory allocation heap.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top