HEAPS
SHEETAL WAGHMAREM.TECH (Computer Science & Data Processing)IIT KHARAGPUR EMAIL-ID: [email protected] [email protected]
SHEETAL WAGHMARE FROM IIT KHARAGPUR
Instruction To Use This Presentation
Dear user I have kept some animated/executable/video files, so it will be easy for you to understand but that will not run/play in slideshow
To see/run that files you have to exit from slideshow then click on the icon and also install KM Player
For example: click on the below icons one by one( one is executable file and other is video) you will be able to see the animation
begin.exe op addatbegin.swf
SHEETAL WAGHMARE FROM IIT KHARAGPUR
What is Heap?Heap is a binary tree which satisfies following two properties
Structure Property : All the level have maximum number of nodes except possibly the last level.In last level all nodes occur to the left.
Heap Order Property: The value in any node N is greater then or equal to the values in both its children.
* A Heap is a complete binary tree and so its height is log2 (n+1)
SHEETAL WAGHMARE FROM IIT KHARAGPUR
Examples
Heap Not an Heap
SHEETAL WAGHMARE FROM IIT KHARAGPUR
MAX HEAP
80
3025
5040
2010
118
80>40 80>50
40>25
40>10 50>20
50>30
25>825>11
Parent node will always have the data greater than childrens
SHEETAL WAGHMARE FROM IIT KHARAGPUR
MIN HEAP
10
6570
5040
6055
8075
40>10 50>10
70>40
55>40 60>50
65>50
75>7080>70
Parent node will always contain the data smaller than childrens
SHEETAL WAGHMARE FROM IIT KHARAGPUR
13
12
6
11
110 9
13
88
99
81
9591 90
MAX HEAP
MIN HEAP
SHEETAL WAGHMARE FROM IIT KHARAGPUR
REHEAP DOWN
(Deletion from Heap)
replacement.exe
REHEAP UP
(Insertion in heap)insertion.exe
SHEETAL WAGHMARE FROM IIT KHARAGPUR
Construction of Heap Using Array
conheap.exe
SHEETAL WAGHMARE FROM IIT KHARAGPUR
THANK YOU