Name

mgsort

Synopsis

int mgsort(void *data, int size, int esize, int i, int k, int (*compare) 
   (const void *key1, const void *key2));

Return Value

0 if sorting is successful, or -1 otherwise.

Description

Uses merge sort to sort the array of elements in data. The number of elements in data is specified by size. The size of each element is specified by esize. The arguments i and k define the current division being sorted and initially should be and size - 1, respectively. The function pointer compare specifies a user-defined function to compare elements. It should perform in a manner similar to that described for issort. When mgsort returns, data contains the sorted elements.

Complexity

O (n lg n), where n is the number of elements to be sorted.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset