0

Example Select x random elements from a weighted list in C# (without replacement)

In this example of random sampling without replacement in c# why did the OP choose to use bitwise operations in the algorithm which counts the total weights and then selects which element is then to be chosen.

I searched the web for other examples of this algorithm but could not find any. Is it more efficient as it seems less readable from my perspective.

thanks.

Community
  • 1
  • 1
wilby55
  • 1
  • 1
  • [Heap (data structure)](https://en.wikipedia.org/wiki/Heap_(data_structure)) – Jeff Mercado Feb 11 '17 at 01:28
  • The only bitwise operations I see in the linked question is doing `i << 1` or `i >> 1`, which is the same as multiplying or dividing by 2. It doesn't seem like it's related to the algorithm in general, but more like a syntactic shortcut to doing those two mathematical operations. – Abion47 Feb 11 '17 at 03:50

0 Answers0