The Gateway to Computer Science Excellence
0 votes
149 views

Link to the question - https://gateoverflow.in/20611/tifr2011-b-30

Someone please simplify that question and explain.

in Algorithms by Loyal (8.3k points) | 149 views

1 Answer

+3 votes
Best answer

Ok so we start with small array of size n = 3

Let the array A looks like:-

3 1 2

and Let array B is empty:-

     

Now in the question, it is given that we will be going to fill the array B with the following equation i.e.

B[A[i]] = i / for all i and i = 1,2,3

Now consider the following table to fill the array B

i A[i]  B[A[i] = i View of Array B
1 3 B[3] = 1 {_ , _ , 1}
2 1 B[1] = 2 {2 , _ , 1}
3 2 B[2] = 3 {2 , 3 , 1}

now after that array B will look like this-

2 3 1

you can see that this is also an permutation ( or another way of arranging the elements) of the elements 1,2,3.

Or in other words, you can say that it is a permutation of array A.

Hence answer is Option B)

Hope this helps ...

by Boss (18.2k points)
selected by
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,542 answers
195,693 comments
101,538 users