Problem 2

Exercise 336.1.

Describe and algorithm to find the size of the largest subset of segments in such that every pair crosses.

Let be the set of points and be the set of edges. Represent edges by objects with properties , , and , where , , and for all edges .

Let be a 2d array such that is an array containing all edges such that sorted in decreasing order of the property . Assign to be the index of in for all .

Let be an array such that is the number of edges satisfying .

Let be a 2d array such that is an array containing all edges such that sorted in decreasing order of the property .

Complexity

The preprocessing requires time. runs in time.