complex-polygon

Testing whether a polygon is simple or complex

For a polygon defined as a sequence of (x,y) points, how can I detect whether it is complex or not? A complex polygon has intersections with itself, as shown: Is there a better solution than checking every pair which would have a time complexity of O(N2)? ...