10
HEAPS SHEETAL WAGHMARE M.TECH (Computer Science & Data Processing) IIT KHARAGPUR EMAIL-ID: [email protected] [email protected]

Heaps

Embed Size (px)

DESCRIPTION

DATA STRUCTURE REHEAP-UP REHEAP-DOWN INSERTION DELETION

Citation preview

Page 1: Heaps

HEAPS

SHEETAL WAGHMAREM.TECH (Computer Science & Data Processing)IIT KHARAGPUR EMAIL-ID: [email protected] [email protected]

Page 2: Heaps

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

Page 3: Heaps

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)

Page 4: Heaps

SHEETAL WAGHMARE FROM IIT KHARAGPUR

Examples

Heap Not an Heap

Page 5: Heaps

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

Page 6: Heaps

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

Page 7: Heaps

SHEETAL WAGHMARE FROM IIT KHARAGPUR

13

12

6

11

110 9

13

88

99

81

9591 90

MAX HEAP

MIN HEAP

Page 8: Heaps

SHEETAL WAGHMARE FROM IIT KHARAGPUR

REHEAP DOWN

(Deletion from Heap)

replacement.exe

REHEAP UP

(Insertion in heap)insertion.exe

Page 9: Heaps

SHEETAL WAGHMARE FROM IIT KHARAGPUR

Construction of Heap Using Array

conheap.exe

Page 10: Heaps

SHEETAL WAGHMARE FROM IIT KHARAGPUR

THANK YOU