Given a collection of classes, what\'s the best way to find the nearest common superclass?
E.g., given the following:
interface A {}
interface B {}
I am also facing this problem right now. I only need the answer on the superclass level. Basically I found it best to only do a O(n) walk through.
You have to define an operation Cmin(A, B) giving you the nearest superclass of class A and class B.
Since Cmin results in a class itself you can use this algorithm:
Result = Cmin Ai | (ai elementIn classes).
gives you O(n).
But remember Java makes a distinction in types being interfaces or classes.