




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























Store points in a priority queue, ordered by their x coordinate.
Along each path keys are monotonically non-decreasing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 left( i ): 2 i if 2 i ≤ n otherwise 0 right(i): (2 i + 1) if 2 i + 1 ≤ n otherwise 0 parent(i): i /2 if i ≥ 2 otherwise 0
There are at most n / h items at height h.
h
h
h
1 2 3 4 5 6 7 8 9
end
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
end end end
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
end end end 8 12 9 10 15 1 2 3 4 5 6 7 8 9
end 3 7