i think its like the generating the the number with equal probability
in given range thats it.if i understood the question correctly
so a shuffle algorithm will do that in o(n) like Knuth Shuffle will do
it so its like shuffling deck of card with equal probability
public static void shuffle(int[] cards)
{
int temp, index;
for (int i = 0; i < cards.length; i++){
index = (int) (Math.random() * (cards.length - i)) + i;
temp = cards[i];
cards[i] = cards[index];
cards[index] = temp;
}
}
Please Let me know if m missing something here
Thanks & Regards
Shashank Mani
CSE, BIT Mesra
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.