Skip to content

Commit 4946788

Browse files
author
fuli
committed
implementing fib-heap
1 parent 648b115 commit 4946788

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

include/fib-heap.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*******************************************************************************
2+
* DANIEL'S ALGORITHM IMPLEMENTAIONS
3+
*
4+
* /\ | _ _ ._ o _|_ |_ ._ _ _
5+
* /--\ | (_| (_) | | |_ | | | | | _>
6+
* _|
7+
*
8+
* FIBONACCI HEAP
9+
*
10+
* In computer science, a Fibonacci heap is a heap data structure consisting of
11+
* a collection of trees. It has a better amortized running time than a binomial
12+
* heap. Fibonacci heaps were developed by Michael L. Fredman and Robert E. Tarjan
13+
* in 1984 and first published in a scientific journal in 1987. The name of
14+
* Fibonacci heap comes from Fibonacci numbers which are used in the
15+
* running time analysis.
16+
*
17+
* http://en.wikipedia.org/wiki/Fibonacci_heap
18+
******************************************************************************/
19+
20+
#ifndef __FIB_HEAP_H__
21+
#define __FIB_HEAP_H__
22+
#include <stdint.h>
23+
namespace alg {
24+
template<typename _Key,typename _Val>
25+
class FibHeap {
26+
public:
27+
typedef _Key key_type;
28+
typedef _Val value_type;
29+
typedef struct node_t {
30+
int32_t degree;
31+
node_t * parent;
32+
node_t * child;
33+
bool mark;
34+
key_type key;
35+
value_type value;
36+
} *Node;
37+
private:
38+
FibHeap(const FibHeap &);
39+
FibHeap& operator=(const FibHeap&);
40+
private:
41+
int32_t n;
42+
Node min;
43+
public:
44+
FibHeap() {
45+
}
46+
};
47+
}
48+
49+
#endif //

0 commit comments

Comments
 (0)