mardi 5 septembre 2023

how to sort and combine random generated numbers without large memory?

I will generate lots of integers range from 0 to about 2^30, a integer may appear multiple times. I want to get a result of a sorted array, contain all these integers without duplicate. Are there good algorithms both in time efficiency and memory efficiency? Before, I store all integers, then sort it and combine the duplicate adjacent integers, but it need large memory. The sorted result array's length may be only 1% of that of all integers array. I also get some idea about hash and binary tree, but don't know how is the performance, need help. And are there good algorithms recommend?




Aucun commentaire:

Enregistrer un commentaire