Part of an assignment for my parallel programming class is to create a file of 313 million unique integers. I figure I’ll multiply two random numbers together to get a very large range, but what is the best way to check for uniqueness?
Should I create an array and search the array each time for matches? That seems as though it will be very inefficient.
Edit – the problem is to eventually sort the list (using threading / multi cores) so having a sequential list doesn’t work.
You could fill the file up sequentially – the resulting file would look like:
These numbers would be very simple to generate, and would be guaranteed to be unique.