Sweep Line Algorithm - Implementation for 1D plane
The problem is simple, There is some given 1D lines on a plane. We need to find the total size of space having at least one line. Let me discuss this with an example image- This may a case . Or This may be a case or anything like this. I know it is a basic problem of Sweep Line Algorithm . But there is no proper document in the internet for it to understand properly. The one best I have is a blog of Top Coder and that is here . But it is not clear how to implement it or how may be the simulation. If I want, we can do it in O(n^2) with 2 loops, but I can't realize how would be the procedure. Or