DAA Case Study
DAA Case Study
RAMAN GLOBAL
UNIVERSITY
BHUBANESWAR, ODISHA
Case Study on :
STRUCTURE OF A FIBONACCI HEAP AND
MERGEABLE OPERATIONS
GUIDED BY:
Dr Supriya Panigrahy
Dept. of Computer Science and
Engineering
Submitted by:
2301020203 YASH SHARMA
2301020219 ADITYA KUMAR SAHOO
2301020226 ANUSHKA MAHARANA
2301020228 ARPEET BARIK
2301020230 ASHUTOSH NAYAK
2301020231 AYUSH ACHARYA
2301020247 ISTA RANJAN BARAL
2301020295 SUBRAT KUMAR BEHERA
2301020309 AKANKSHYA PRADHAN
2301020320 SRILIP SAHOO
INTRODUCTION
A Fibonacci heap is a data structure used for
implementing priority queues. It is a type of heap data
structure, but with several improvements over the
traditional binary heap and binomial heap data
structures. The key advantage of a Fibonacci heap over
other heap data structures is its fast amortized running
time for operations such as insert, merge and extract-
min, making it one of the most efficient data structures
for these operations. The running time of these
operations in a Fibonacci heap is for insert, for extract-
min and amortized for merge. A Fibonacci heap is a
collection of trees, where each tree is a heap-ordered
multi-tree, meaning that each tree has a single root
node with its children arranged in a heap-ordered
manner. The trees in a Fibonacci heap are organized in
such a way that the root node with the smallest key is
always at the front of the list of trees. In a Fibonacci
heap, when a new element is inserted, it is added as a
singleton tree. When two heaps are merged, the root
list of one heap is simply appended to the root list of
the other heap. When the extract-min operation is
performed, the tree with the minimum root node is
removed from the root list and its children are added to
the root list. One unique feature of a Fibonacci heap is
the use of lazy consolidation, which is a technique for
improving the efficiency of the merge operation. In lazy
consolidation, the merging of trees is postponed until it
is necessary, rather than performed immediately. This
allows for the merging of trees to be performed more
efficiently in batches, rather than one at a time. A
Fibonacci heap is a highly efficient data structure for
implementing priority queues, with fast amortized
running times for operations such as insert, merge and
extract-min. Its use of lazy consolidation and its multi-
tree structure make it a superior alternative to
traditional binary and binomial heaps in many
applications.
Memory Representation Of
Fibonacci Heap
Key: the value of the node.
Degree: the number of children the node has.
Parent: a pointer to the parent node.
Child: a pointer to the first child node.
Left: a pointer to the node to the left of the current
node in the doubly linked list.
Right: a pointer to the node to the right of the current
node in the doubly linked list.
Insert(x):
Inserts node x into the heap
Time complexity: O(1)
Find-min():
Returns the node with the smallest key
Time complexity: O(1)
Union(H1, H2):
Merges two heaps, let’s say H1 and H2
Time complexity: O(1)
Extract-min():
Removes and returns the minimum node
Time complexity: O(log n)
Decrease-key(x, k):
Decreases the key of node x to k
Time complexity: O(1)
Delete(x):
Removes node x from the heap
Time complexity: O(log n)
INSERTION
ALGORITHMS
1. insert(H, x)
2. degree[x] = 0
3. p[x] = NIL
4. child[x] = NIL
5. left[x] = x
6. right[x] = x
7. mark[x] = FALSE
8. Concatenate the root list containing x with root list H
9. if min[H] == NIL or key[x] < key[min[H]]
then min[H] = x
10.n[H] = n[H] + 1
Inserting a node into an already existing heap follows the steps
below.
Create a new node for the element.
Check if the heap is empty.
If the heap is empty, set the new node as a root node and mark
it min.
Else, insert the node into the root list and update min.
Union