views:

24

answers:

2
A: 

Follow these basic steps.

  1. Find files without any dependencies
  2. Add those to the build first
  3. Find files dependent on those in build and nothing else
  4. Add those to build next
  5. Repeat 3 and 4 until all files in build

You'll need some checks to detect circular dependencies which would cause and endless loop on step 5. Other than that, this should work.

Sam
+1  A: 

The algorithm you are looking for is called topological sorting.

Anton Tykhyy