reopened by
641 views
0 votes
0 votes
What does it mean when they say "An array A[1...n] consists of a permutation of numbers 1....n.".?

Also I'd be grateful if you give some example.
reopened by

2 Answers

1 votes
1 votes

let n=2 
A[1,2] and it consists of a permutation of numbers 1,2 which are  
case 1: (1,2) 
case 2: (2,1) 
B[A[i]]:=i  for all i (GIVEN) 
case 1: B[A[1]]:=1 B[1]:=1 
             B[A[2]]:=2 B[2]:=2 so B=(1,2) 
case 2: B[A[1]]:=1 B[2]:=1 
             B[A[2]]:=2 B[1]:=2 so B=(2,1) 
Hence array B have permutation of 1,2

Ans is B

source: https://gateoverflow.in/20611/tifr2011-b-30

Related questions

0 votes
0 votes
0 answers
4