1 / 11

Advanced Data Structures - Binary Heap

This presentation is brought to you by Prof. Ajitkumar Shitole, Department of Computer Engineering of International Institute of Information Technology, I²IT, Pune. The presentation explains the advanced data structure of Binary heap, a special kind of binary tree.

Télécharger la présentation

Advanced Data Structures - Binary Heap

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BINARY HEAP

  2. HOPE FOUNDATION’S INTERNATIONAL INSTITUTE OF INFORMATION TECHNOLOGY, (I²IT) www.isquareit.edu.in +91 20 22933441 / 2

  3. Binary Heap A special kind of binary tree. It has two properties that are not generally true for other trees: Completeness / Heap Structure: The tree is complete, which means that nodes are added from top to bottom, left to right, without leaving any spaces. A binary tree is completely full if it is of height, h, and has 2h+1-1 nodes. Heapness / Heap Order: The item in the tree with the highest priority is at the top of the tree, and the same is true for every sub tree.

  4. Binary Heap • Max Heap: A heap is a binary tree in which every parent is greater than its child(ren). 2. Min Heap: A Reverse Heap is one in which the rule is “every parent is less than the child(ren)”.

  5. Binary Heap To build a heap, data is placed in the tree as it arrives. Algorithm: • add a new node at the next leaf position • use this new node as the current position • While new data is greater than that in the parent of the current node: ● move the parent down to the current node ● make the parent (now vacant) the current node ● Place data in current node

  6. Binary Heap New nodes are always added on the deepest level in an orderly way. The tree never becomes unbalanced. A heap is not a sorted structure. Can be regarded as partially ordered. A given set of data can be formed into many different heaps (depends on the order in which the data arrives.)

  7. Binary Heap Example: Data arrives to be heaped in the order: 54, 87, 27, 67, 19, 31, 29, 18, 32

  8. 54 87 87 87 87 87 27 27 27 27 67 87 54 54 67 54 67 54 54 19 Binary Heap 54, 87, 27, 67, 19, 31, 29, 18, 32 54 Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in

  9. 87 87 67 67 27 27 19 19 54 54 Binary Heap 54, 87, 27, 67, 19, 31, 29, 18, 32 31 Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in

  10. 87 87 67 67 31 31 27 27 29 29 19 19 54 54 Binary Heap 54, 87, 27, 67, 19, 31, 29, 18, 32 18 32 Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057 Tel - +91 20 22933441 / 2 / 3 | Website - www.isquareit.edu.in ; Email - info@isquareit.edu.in

  11. THANK YOU For further information please contact Prof. AjitkumarShitole Department of Computer Engineering Hope Foundation’s International Institute of Information Technology, I²IT Hinjawadi, Pune – 411 057 Phone - +91 20 22933441 www.isquareit.edu.in | ajitkumars@isquareit.edu.in

More Related