selfcompiler's blog

By selfcompiler, 12 years ago, In English

ou are given an array B of n integers. Then the array A is created using array B as following : for each i (1 <= i <= n), we set Ai = Bi + d with the probability Pi, otherwise Ai = Bi. find the expect number of swaps that bubble sorting will make when the array A is sorted .......

for example if input is this n=4 d=7 elements of array B = 5 6 1 7 probability of array of elements B = 25 74 47 99\ answer=1.6049

Full text and comments »

  • Vote: I like it
  • -45
  • Vote: I do not like it