Probably best illustrated with a small example.
Given the relations
A < B < C
A < P < Q
Correct outputs would be
ABCPQ or APQBC or APBCQ ... etc.
In other words, any ordering is valid in which the given relationships hold.
I am most interested in the solution that is easiest to implement, but the best O(n) in speed and time is int...
While reading another question, i came to a problem with partial ordering, which i cut down to the following test-case
template<typename T>
struct Const { typedef void type; };
template<typename T>
void f(T, typename Const<T>::type*) { cout << "Const"; } // T1
template<typename T>
void f(T, void*) { cout << "void*"; } // T2
int main(...
I have a list of items that have a partial order relation, i. e, the list can be considered a partially ordered set. I want to sort this list in the same way as in this question. As correctly answered there, this is known as topological sorting.
There's a reasonably simple known algorithm to solve the problem. I want a LINQ-like impleme...