Given two sets P1, P2
of points in a plane.
Solution: If there is a line which separates the points of P1
from P2
, a line that holds that all points in P1
are on one side and all points in P2
are on the other side, return 'There is such line', otherwise return 'There is no such line'.
Example: consider these points: 5 = (−2,1) ,4 = (6,2) ,3 = (2, −2) ,2 = (1,5) ,1 = (−2, −1).
P1 = {1,2} and P1 = {3,4}
---> return 'There is such line' y = 2x-3
for example.
whereas P1 = {1,2} and P1 = {3,4,5}
---> return 'There is no such line'.
Is there a linear designed based algorithm which doesn't use convex hulls to solve this problem? I'll be happy for suggestions!