Heaps

 A Binary Heap is either Min Heap or Max Heap.
Min Binary Heap: the key at root must be minimum among all keys present in Binary Heap. the same property must be recursively true for all nodes in Binary Tree.
Min Binary Heap: The key at root must be maximum among all keys present in Binary Heap. the same property must be recursively true for all nodes in Binary Tree.

Binamial Heap:
Binamial Heap  is a Extention of Binary Heap that provides faster union or merge operations together with other operations provided by Binary Heap.

Is a collection of tinomial trees.

Binamial Tree Tree: A binomial Tree of order 0 has 1 node. A binomial Tree oder k can be constructed by taking two binomial trees of order k-1, and making one as leftmost child of other.

 Binomial Heap:
Is a set of Binomial Tree where each Binomial Tree follows Min Heap Property. and there can be at-most one Binomial Tree of any degree.


















Fibonacci Heap:
 In terms of Time Complexity, Fibonacci Heapbeats both Binary and Binomial Heaps.
 

  • Find : O(1)    - same as both
  • Delete : O(log n)  - same as both
  • Insert : O (1)   - O(lon n) in Binary , O(1) in binomial
  • Decrease-Key : O (1) - O(log n) in both
  • Merge : O (1)  :  O(m log n) or O(m+n) in Binary , O(log n) in Binomial.
Fibonacci Heap is 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.

 

Leftist Tree / Leftist Heap:

In this Every node has an s-value ( or rank or distance) which is the distance to the nearest leaf. a leftist tree may be very unbalanced.

A leftist tree is a binary tree with properties:

1. Normal Min Heap Property: key(i) >= key(parent(i))

2.Heavier on Left side: dist(right(i)) <= dist(left(i)).

   Here dist(i) - is no of edges on the shortest path from node i to a leaf node in extended binary tree representaion.






 








Comments

Popular posts from this blog

Tournament Tree or Winner Tree

Linked List