in reply to [OT] A measure of 'sortedness'?
Not sure what do you need to do with the merged data, but assuming the individual elements are sufficiently large, what about using and keeping the 10% buffer as an "array of references" instead. It's true than when looping through the merged data, you'd have to do an array accesses and dereference instead of one array access, but it still might work out.
What I mean is that having
you'd build@A = qw(a d f i j k l m o q); @B = qw(c e g h p r s t v w);
by a simple, O(n), merge and then the n-th element of the result would be ${$ref[$n]}.@ref = (\$A[0] \$B[0] \$A[1] \$B[1] \$A[2] \$B[2] \$B[3] \$A[3] \$A[4] + \$A[5] \$A[6] \$A[7] \$A[8] \$B[4] \$A[9] \$B[5] \$B[6] \$B[7] \$B[8 +] \$B[9]);
You'd need the buffer to be able to hold 2*n references.
When merging with the next two buffers with their own reference array, you'd need another 4*n*size-of-reference buffer to do the merge and then you'd drop the two old reference arrays.
Jenda
Enoch was right!
Enjoy the last years of Rome.
|
|---|