Presentation is loading. Please wait.

Presentation is loading. Please wait.

SNS COLLEGE OF TECHNOLOGY (Autonomous ) COIMBATORE-35

Similar presentations


Presentation on theme: "SNS COLLEGE OF TECHNOLOGY (Autonomous ) COIMBATORE-35"— Presentation transcript:

1 SNS COLLEGE OF TECHNOLOGY (Autonomous ) COIMBATORE-35
Recap AVL Tree (Double Rotation) Double Rotation(Left Right Rotation) Double Rotation(Right Left Rotation) 16IT201/Data Structuress- Unit - II/Binary Heaps

2 SNS COLLEGE OF TECHNOLOGY (Autonomous ) COIMBATORE-35

3 16IT201/Data Structuress- Unit - II/Binary Heaps
Binary Heap Refereed to as Heaps. Heap have two property -Structure Property & Heap Order Property 16IT201/Data Structuress- Unit - II/Binary Heaps

4 16IT201/Data Structuress- Unit - II/Binary Heaps
Types of Heap 16IT201/Data Structuress- Unit - II/Binary Heaps

5 16IT201/Data Structuress- Unit - II/Binary Heaps
Heap Strucutre Binary Tree with Structure and Heap Order property Binary Tree with Structure but violating Heap Order property 16IT201/Data Structuress- Unit - II/Binary Heaps

6 Binary Heap Operations
Insert Operations & DeleteMin Operations To Perform Insert and DeleteMin operations ensure that heap order property is maintained 16IT201/Data Structuress- Unit - II/Binary Heaps

7 Insert a node - percolate up
If the new node has a greater value than the parent of the hole - we insert the node in the hole. Thus, if the new value to be inserted is 18, our new binary heap would be: A hole is created at the bottom of the tree, in the next available position. 16IT201/Data Structuress- Unit - II/Binary Heaps

8 Insert a node - percolate up
we want to insert is less than 17, so we slide down 17, and the hole appears at the node where 17 used to be Since 16 is less than 10, we can insert it in the hole: Complexity of insertion: O(logN) in the worst case. 16IT201/Data Structuress- Unit - II/Binary Heaps

9 Can u find the error in this pic
16IT201/Data Structuress- Unit - II/Binary Heaps

10 16IT201/Data Structuress- Unit - II/Binary Heaps

11 16IT201/Data Structuress- Unit - II/Binary Heaps

12 16IT201/Data Structuress- Unit - II/Binary Heaps

13 16IT201/Data Structuress- Unit - II/Binary Heaps
Explanation: From Equation 1: 1 Shape = 45/3 = 15 Now if you notice there are 15 sides in 1 shape, thus each side contributes to value of 1. From 2nd Equation: 4 Bananas + 4 Bananas + 15 sides shape = 23 8 bananas = 23 – 15 = 8 => 1 Banana = 1 From 3rd equation => 2 clocks = 10 – 4 = 6 => 1 clock = 3 now here also if you notice, clock time in hour represents its value in the equation thus Clock with 2 o clock + 3 Bananas + 3 Bananas * Shape with 11 sides = *11 = = 38 16IT201/Data Structuress- Unit - II/Binary Heaps

14 16IT201/Data Structuress- Unit - II/Binary Heaps
DeleteMin 16IT201/Data Structuress- Unit - II/Binary Heaps

15 16IT201/Data Structuress- Unit - II/Binary Heaps
For Each of the following list construct an AVL tree by inserting their element successfully starting with the empty tree A) 1,2,3,4,5,6 B)6,5,4,3,2,1 C)2,1,4,5,9,3,6,7 D) 15, 20, 24, 10, 13, 7, 30, 36, 25 16IT201/Data Structuress- Unit - II/Binary Heaps

16 Binary Heap Properties
Summarization Binary Heap Properties Min Heap & Max Heap Heap Opeartions 16IT201/Data Structuress- Unit - II/Binary Heaps

17 A wonderful moving bicycle illusion
16IT201/Data Structuress- Unit - II/Binary Heaps


Download ppt "SNS COLLEGE OF TECHNOLOGY (Autonomous ) COIMBATORE-35"

Similar presentations


Ads by Google