Question: would someone please explain this example and its answer. I understand if an array has {3,2,6} then its inverse would be {6,2,3}. Is this what being asked because the piece of code below doesn't seem to achieve this?

Suppose that the array int pi[128] contains a permutation of the numbers 0, 1, ...., 127.

What one or two lines of Java code would you use to efficiently produce the inverse of
pi in the array ip[128]?

**ANSWER:** 

```
 for (i=0; i<128; ++i) 
      ip[pi[i]] = i

```

Answer: 
This is an "inverse permutation" for permutation $\pi$, in the sense any mathematician would use. <http://mathworld.wolfram.com/InversePermutation.html>
An inverse permutation is a permutation which you will get by inserting position of an element at the position specified by the element value in the array.