I need to sort data blocks that are stored in an array of structures. Structures do not have pointers. Each block has a counter number and location coordinates in the array, where the data block is equal to the structural block. For example, if we have a data array that we can divide into 4 NxN blocks, we have 4 structural blocks in the index array of structural blocks, and each of them has its own number and position in the data array, with which we can calculate block pointer in the data array using the index block. Sorting should be performed using a comparator, which compares two blocks so that the smallest of the two blocks has the smallest number of the i-th number. For example, a comparator:
for( i = 0; i < N * N; ++i )
{
if( a[i] < b[i] ) return -1;
if( a[i] > b[i] ) return 1;
}
where aand bare pointers to blocks of the array of data that we can get out of the index of the array and the data start pointer array. Sorting should not sort the data array, but an indexed array. Thus, the question arises: what parallel algorithm can I use (except for frameworks, libraries, do I need algorithms or standard language suites like pthread or qt libs or standard c / C ++ libraries) to avoid synchronization errors? It is also useful to use code or pseudo code.
source
share