1 / 10

Binary Heap - Department of Computer Engineering

This presentation discusses Binary Heap and is presented by Prof. Ajitkumar Shitole, from the department of Computer Engineering at International Institute of Information Technology, Iu00b2IT. The presentation covers topics like Binary Tree, Max Heap, Min Heap and how to build them along with algorithm.<br>

Download Presentation

Binary Heap - Department of Computer Engineering

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 • Prof ajitkumarshitoleAssistant ProfessorDepartment of computer engineeringHope Foundation’sInternational Institute of Information Technology, I²ITwww.isquareit.edu.in

  2. Binary Heap Special type of a binary tree. Two properties must be satisfied. Completeness / Heap Structure: Binary tree is either complete or almost complete binary tree in which all levels are completely filled from top to bottom and left to right except bottommost level which may or may not be filled completely. Heapness/ Heap Order: The value of parent node is greater than either child in case of max heap and is less than either child in case of min heap. Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  3. Binary Heap • Max Heap: A heap is a binary tree in which every parent node value is greater than its children. 2. Min Heap: A heap is a binary tree in which every parent node value is smaller than its children. Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  4. Binary Heap To build a heap, data is placed in the tree as it arrives. Algorithm: • Insert 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 Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  5. Binary Heap As new node is always inserted at the last level, heap never becomes unbalanced. A heap is a partially sorted data structure. A given set of data can be formed into many different heaps (depends on the order in which the data arrives.) Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  6. Building Max Binary Heap Example: Data arrives to be heaped in the order: 55, 88, 28, 68, 20, 32, 30, 19, 33 Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  7. 55 88 88 88 88 88 28 28 28 28 68 88 55 55 68 55 68 55 55 20 Max Binary Heap 55, 88, 28, 68, 20, 32, 30, 19, 33 55 Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  8. 88 88 68 68 28 28 20 20 55 55 Max Binary Heap 55, 88, 28, 68, 20, 32, 30, 19, 33 32 Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  9. 88 88 68 68 32 32 28 28 30 30 20 20 55 55 Max Binary Heap 55, 88, 28, 68, 20, 32, 30, 19, 33 19 33 Hope Foundation’s International Institute of Information Technology, I²IT P-14,Rajiv Gandhi Infotech Park MIDC Phase 1, Hinjawadi, Pune – 411057 Tel - +91 20 22933441/2/3 | www.isquareit.edu.in | info@isquareit.edu.in

  10. 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 | info@isquareit.edu.in

More Related