1. Engineering
  2. Computer Science
  3. question 6 short description a write a function which determines...

Question: question 6 short description a write a function which determines...

Question details

QUESTION 6: Short description: A. Write a function which determines if a given array of n integers is a permutation of (e. .n-1). B. Write a function which takes a permutation of n integers and constructs its inverse. Background recall that a permutation of a set of integers is just an ordered listing of the elements. For example, consider the set S- 0, 1, 2) . example permutations of S These are not permutations of S Suppose an array of integers is indeed a permutation of 0.n-1 . We can view such an array as a bijective function f from POSITION-to-ELEMENT-AT-INDEX Since f is a bijection, it also has an inverse which is a function from ELEMENT-to-POSITION-OF- ELEMENT Examples of permutations of (e,1,2) and their inverses as array diagrams: Permutation Inverse val val idx 2 idx val idx idx val 1 va 2 idx idx

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution