Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am stuck in this problem. Can anyone help me. Thanks.

Consider an array 'A' of 1st n natural numbers randomly permuted. Consider an array B formed from array A as given below

B(k) = number of elements from A(1) to A(k-1) which are smaller than A(k)

Obviously B(1) = 0;

i) Given A can you find B in O(n)

ii) Given B can you find A in O(n)

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.