2 ms·
From a more algorithmic point of view, this is exactly the task of topological sorting [1]. And it runs linearly in the number of edges! I expect Prolog to be
by Labo333 4y ago
From a more algorithmic point of view, this is exactly the task of topological sorting [1].
And it runs linearly in the number of edges!
I expect Prolog to be slower for large and hard inputs. But Makefiles solve exactly that!
[1]: https://en.m.wikipedia.org/wiki/Topological_sorting https://en.m.wikipedia.org/wiki/Topological_sorting