Adjacency using a Balanced Tree
Need the following operations:
Insert segment
Delete segment
Tell me the two segments
adjacent to this one (along
the sweepline)
Swap two segments along
the sweepline (needed when
an intersection occurs)
We can use a balanced tree!
Runtime analysis
The loop is executed O(n+k)
times where k is the number
of intersections
Each PQ operations within
the loop takes time O(log n)
(using a heap)
The operations needed to
maintain adjacency
information each take time
O(log n) (using a balanced
tree)
Total time: O((n+k)log n)
CS409 - Spring 2000
6