Inverse Permutation Question in c++ 2011-12
Inverse permutations from an array of permutations. It's my first time coding on permutations so I don't have any experience on this. So I came up with a solution to just swap the array and the element number as the inverted permutation

Sponsored Links

v
Code:
oid inverse ( unsigned ip[], const unsigned p[], unsigned elements ) {
	unsigned tempArray = 0, tempIndex = 0;
	for (int i = 0; i < elements; i++ ) {
		tempIndex = i;
		tempArray = p[i];
		ip[tempArray] = tempIndex;
	}
	show ( ip, 5 );
}