I came up with a rather naive recursive algorithm (pseudocode):
Map<Object, List<Object>> source;
The biggest problem is that it does not have the ability to detect circular dependencies - it can go into infinite recursion (i.e. stack overflow; -p). The only way I can see is to turn the recursive algorithm into an interactive one with a manual stack and manually check the stack for repeated elements.
Does anyone have something better?
Kieron Aug 07 '08 at 0:30 2008-08-07 00:30
source share