Compute the minimal number of swaps to order a sequence
I was able to prove this with graph-theory. Might want to add that tag in 🙂 Create a graph with n vertices. Create an edge from node n_i to n_j if the element in position i should be in position j in the correct ordering. You will now have a graph consisting of several non-intersecting … Read more