Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

CSCI3320/8325: Data Structures 1

CSCI3320/8325: Data Structures 2


The subtree at node 7 violates the
property of leftist heap so we swap it
with the left child and retain the
property of leftist heap.

CSCI3320/8325: Data Structures 3


CSCI3320/8325: Data Structures 4
CSCI3320/8325: Data Structures 5
CSCI3320/8325: Data Structures 6
CSCI3320/8325: Data Structures 7
CSCI3320/8325: Data Structures 8
CSCI3320/8325: Data Structures 9
CSCI3320/8325: Data Structures 10
CSCI3320/8325: Data Structures 11
CSCI3320/8325: Data Structures 12
E.g. a binomial heap with 13 nodes
will consist of three binomial trees of
orders 3, 2, and 0

CSCI3320/8325: Data Structures 13


CSCI3320/8325: Data Structures 14
3. deleteMin(H): This operation also
uses union(). We first call getMin() to
find the minimum key Binomial Tree,
then we remove the node and create a
new Binomial Heap by connecting all
subtrees of the removed minimum
node. Finally, we call union() on H
and the newly created Binomial Heap.
This operation requires O(Log n)
time.

CSCI3320/8325: Data Structures 15


CSCI3320/8325: Data Structures 16
CSCI3320/8325: Data Structures 17
CSCI3320/8325: Data Structures 18
CSCI3320/8325: Data Structures 19
CSCI3320/8325: Data Structures 20
CSCI3320/8325: Data Structures 21
Like Binomial Heap, Fibonacci Heap is a collection of trees with min-heap or max-heap
property. In Fibonacci Heap, trees can have any shape even all trees can be single nodes
(This is unlike Binomial Heap where every tree has to be Binomial Tree).

CSCI3320/8325: Data Structures 22


Fibonacci Heap maintains a pointer to minimum value (which is root of a tree). All tree roots are
connected using circular doubly linked list, so all of them can be accessed using single ‘min’
pointer.
The main idea is to execute operations in
“lazy” way. For example merge operation
simply links two heaps, insert operation
simply adds a new tree with single node.

Delete min O(log n)


1. Delete min and concatenate its children
into root list
2. Consolidate trees so that no two roots have
same degree.

CSCI3320/8325: Data Structures 23

You might also like