Line Segments Intersection


Two algorithms were implemented for line segments intersection: the brute force (left) - every two line segments are checked for intersection) and Balaban's algorithm (right). The left one has an asimptotic running time of O(n2); the right one has an asimptotic running time of O(n log2(n)+k) where n is the number of segments and k is the number of intersection points.