HEAPS
SHEETAL WAGHMARE
M.TECH (Computer Science & Data Processing)
IIT KHARAGPUR
EMAIL-ID: shitu2iitkgp@gmail.com
sheetalw3@gmail.com
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
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
30
25
5040
2010
11
8
80>40 80>50
40>25
40>10 50>20
50>30
25>8
25>11
Parent node will always have the data greater than childrens
SHEETAL WAGHMARE
FROM IIT KHARAGPUR
10
65
70
5040
6055
80
75
40>10 50>10
70>40
55>40 60>50
65>50
75>70
80>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)
REHEAP UP
(Insertion in heap)
SHEETAL WAGHMARE
FROM IIT KHARAGPUR
SHEETAL WAGHMARE
FROM IIT KHARAGPUR
Construction of Heap Using Array
SHEETAL WAGHMARE FROM IIT KHARAGPUR

Heaps

  • 1.
    HEAPS SHEETAL WAGHMARE M.TECH (ComputerScience & Data Processing) IIT KHARAGPUR EMAIL-ID: shitu2iitkgp@gmail.com sheetalw3@gmail.com
  • 2.
    Instruction To UseThis 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 SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 3.
    What is Heap? Heapis 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
  • 4.
    Examples Heap Not anHeap SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 5.
    MAX HEAP 80 30 25 5040 2010 11 8 80>40 80>50 40>25 40>1050>20 50>30 25>8 25>11 Parent node will always have the data greater than childrens SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 6.
    10 65 70 5040 6055 80 75 40>10 50>10 70>40 55>40 60>50 65>50 75>70 80>70 Parentnode will always contain the data smaller than childrens SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 7.
    13 12 6 11 110 9 13 88 99 81 9591 90 MAXHEAP MIN HEAP SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 8.
    REHEAP DOWN (Deletion fromHeap) REHEAP UP (Insertion in heap) SHEETAL WAGHMARE FROM IIT KHARAGPUR
  • 9.
    SHEETAL WAGHMARE FROM IITKHARAGPUR Construction of Heap Using Array
  • 10.
    SHEETAL WAGHMARE FROMIIT KHARAGPUR