I want to visualize two different algorithms that decide if there's overlap in a collection of circles in a plane in Java:
- an O(n²) algorithm that checks every combination of circles
- an O(nlogn) algorithm using a sweep line
Is there a way to let an object of a vizualization class 'listen' to an object of the algorithm class in a way that it can for example see when the algorithm is performing an overlap check between a pair of circles and knows when to update the visualization?
other example: I can keep the list of active circles(those which intersect the sweep line) as a variable of the sweep line algorithm and let another class(visualization class) get that variable. But how will that class know when the list is updated and it has to update the visualization?
That's just the strategy I was thinking of. Maybe there are better ways...