Professional Documents
Culture Documents
Deaps: By: Michael Gresenz Austin Forrest
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, and delete-max. Similar to min-max heap but deap is faster on these operations by a constant factor, and the algorithms are simpler.
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.
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 < 45 ; 10 <25 ; 8 <40; 15 < 20; 19 < 25; 9 < 40; 30 < 40
5 10 8 25
45
40
15
19
7 9
30 8
20
Min heap
Max heap
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
Deaps-Insert 4
5 10 8 25
45
40
15
19
7 9
30 8
20
Deaps-Insert 60
4 5 8 25
45
40
15
10
7 9
30 8
20
19
60
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
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
Testing
Random number generator Symbols Letters Zero