Suppose I am given number of lines segments in Cartesian coordinate system.Each line is given as [x0,y0] and [x1,y1].Algorithm should find a perpendicular that cross maximum number of lines.
In this example it crosses four lines:

What algorithm can do it with minimum complexity?(i would prefer c++ but some kind of pseudo code is OK too)
P.S The point to think about is when several lines start/end in the same x coordinate
Thank you.
O(n lg n) time complexity