Tuesday, 17 September 2013

Insert unique random numbers in array

Insert unique random numbers in array

Hi am newbie to algorithm and wanted to check if given an array of n
elements, what is the best way to fill random elements in it without any
duplication. I dont want to use the C++ STL containers, else I can surely
find a way around like using set and random_shuffle.
Also when I say, I want random numbers to fill in n blocks, it doesnt
necessarily mean 1 to n values . eg array of size 4 can have values
{3,214,5124,24}, not 1-4 Also I would be just using random function to
generate random number.

No comments:

Post a Comment