0

Good day to all, I'm doing a project about 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. Here's my code by the way, I'm just wondering if the "seasoned" members here have any tips on doing an inverted permutation properly.

Please let me know if you guys have any advice. Thanks!

```
void 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 );
}
```