Here you can ask questions and find or give answers to organizational, academic and other questions about studying computer science.

1.2k questions

1.3k answers

1.7k comments

581 users

0 votes
In PRAM basic page 56, why after firstC calculation, we are again trying to get firstC'? The decrementing value of FirstC I am not getting properly. Even in the code snippet also it is not written to calculate for the firstC'.
in # Study-Organisation (Master) by (480 points)

1 Answer

0 votes
For the algorithm, we split the arrays a and b into m blocks of size m, and then we want to find for every i=0...m-1 the index j such that we have b[(j-1)*m]<=a[i*m]<b[j*m] because then, we know that block a[i*m..i*m+m-1] must be merged in somewhere in the block starting in b[(j-1)*m].

To find these indices j, we first compute in array firstC for every i=0...m-1 the least index j such that a[i*m]<b[j*m] holds. Hence, we then have b[(j-1)*m]<=a[i*m]<b[j*m]. To get j-1 instead of j, we finally decrement the values in array firstC and store the values j-1 in array firstC'.
by (171k points)

Related questions

Imprint | Privacy Policy
...