#include "distribution_counting.h"
/* [Distribution Counting Sort]
* First used with radix sorting by H.Seward, 1954.
* Then published with "Mathsort" by W.Feurzeig, CACM 3 (1960), 601
*/
static int *counting_table = NULL;
static int cur_table_len = 0;
static int
create_counting_table(int cnt)
{
F_S();
counting_table = (int*)malloc(sizeof(int) * cnt);
if(counting_table == NULL) {
debug("malloc failed. [%s] \r\n", __FUNCTION__);
return 0;
}
cur_table_len = cnt;
F_E();
return 1;
}
void
free_counting_table(void)
{
F_S();
if (counting_table == NULL) return;
free(counting_table);
counting_table = NULL;
cur_table_len = 0;
F_E();
}
/* we guess all the items located in [@min, @max],
* and do the counting for sorting.
*/
int*
do_distribution_counting_sort(void* src, int src_sz, int item_cnt, int min, int max, void *out,
GET_ITEM_FUNC get_item, SE
Foundation: Comparison Counting Sort
最新推荐文章于 2021-02-09 16:36:13 发布
本文探讨了排序算法中的基数计数排序方法,深入解析其原理和应用,适合对基础算法感兴趣的读者。
摘要由CSDN通过智能技术生成