Parallel Merge Sort

Ali Çehreli via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 4 15:23:56 PST 2015


On 03/04/2015 02:18 PM, Josh wrote:

 > now say A[] was = [90, 50, 33, 72, 35]
 >
 > and by the end of the function B[] = [33, 50, 72, 90, 35]
 >
 >
 > now we call swap(A,B) and A would now = [33, 35, 50, 72, 90]
 >
 > and somehow the 35 moves in front of the 50.

Not for me. I think there is bug in the algorithm:

     auto a = [90, 50, 33, 72, 35];
     a.mergeSort;
     assert(a == [33, 50, 72, 90, 35]);    // Incorrect ordering :(

Ali



More information about the Digitalmars-d mailing list