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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.