Heap is a concept which can be implemented on trees, priority queues and arrays. When we plot a heap on paper, we draw it as binary tree. We also analyse a heap as a binary tree. There are 2 types of heaps:
1. min heap: parent node is always less than both children.
2. max heap: parent node is always greater than both children.
In both the cases equality is permitted. No other property is required for a heap. We do not care about any other thing like which child is greater.
Heap can be utilized in
1. heapsort
2. a priority queue can be implemented with a heap
3. auto balancing binary tree
For general purposes this much on heap is enough. For more you can study in details on wikipedia.
1. min heap: parent node is always less than both children.
2. max heap: parent node is always greater than both children.
In both the cases equality is permitted. No other property is required for a heap. We do not care about any other thing like which child is greater.
Heap can be utilized in
1. heapsort
2. a priority queue can be implemented with a heap
3. auto balancing binary tree
For general purposes this much on heap is enough. For more you can study in details on wikipedia.
No comments:
Post a Comment
feel free to ask your doubts... if any
you can post your doubts on
www.facebook.com/programsimply