Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,

Similar presentations


Presentation on theme: "DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,"— Presentation transcript:

1 DEAPS By: Michael Gresenz Austin Forrest

2 Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min, and delete-max. Similar to min-max heap but deap is faster on these operations by a constant factor, and the algorithms are simpler.

3 Deaps A deap is a complete binary tree that is either empty or satisfies the following properties: –The root contains no element –The left subtree is a min heap. –The right subtree is a max heap. –If the right subtree is not empty, then let i be any node in the left subtree. Let j be the corresponding node in the right subtree. If such a j does not exist, then let j be the node in the right subtree that corresponds to the parent of i. The key in node i is less than or equal to that of j.

4 Modules Insert –Insert a new element with an arbitrary value Delete min –Delete an element with minimum key Delete max –Delete an element with maximum key

5 8 10 7 2540 1519 45 7 9 30 8 5 20 Min heap Max heap 小 大 5 < 45 ; 10 <25 ; 8 <40; 15 < 20; 19 < 25; 9 < 40; 30 < 40

6 Insert Similar to normal insert into heap The new value when inserted into deap, if it is in the left subtree will move up using a compare for a min heap and if it is in the right subtree it will move up using a compare for a max heap

7 8 10 7 2540 1519 45 7 9 30 8 5 20 Deaps-Insert 4 4

8 8 5 7 2540 1510 45 7 9 30 8 4 20 Deaps-Insert 60 1960

9 Delete min Deletes the min value in heap Rearranges the heap so it is still a min heap in left subtree and max heap in right subtree

10 Delete max Deletes the max value in heap Rearranges the heap so it is still a min heap in left subtree and max heap in right subtree

11 Testing Random number generator Symbols Letters Zero Try to ensure that the program doesn’t crash


Download ppt "DEAPS By: Michael Gresenz Austin Forrest. Deaps A deap is a double-ended heap that supports the double-ended priority operations of insert, delete-min,"

Similar presentations


Ads by Google