c++ - implemenation of sets using bits -
I'm reading about the set set as bits in the following location
To insert any item in the set, we have to change the appropriate bit in a bit array. The ith bit bit bit of bit array is mod w of the word roof (i / w). Thus, the insertion function is implemented using the beetwold or operation so that it is shown in the above program. Although this is slightly more complex than the SetAsArray class for this operation, the time to run for this operation is still (1). Since w = word bits have the power of two, it is possible to change the division and modulo operations, and with%, such shifts and masks:
vector [items] changes | = 1 & lt; & Lt; (Items and masks);
Question
Li>
I have a question in the constructor why why is the author subtracting the word "B" from 1, instead we can use it directly as n / wordbits?
The second question is whay by the statement of the author "ince w = wordbits is the power of two, split and modulo operation, and /, and replace with shift, mask like this Possible:
vector [item] change | | = 1 << p>
In the case of requesting an example that is the value of change and the mask.
- Why is the author mentioned on the basis of architecture and compiler?
< / Ol>
I have re-tagged it as C ++ because it is not explicitly.
- For example, if you say that it is equal to something like
wordBits
fromn
, the generic formula is being used exactly, i.e.B = (a + q - 1) / q
ensures thatb * q
is less thana
. - The original binary Arithmetic Is equal to the queen and so on.
- On some machines, speeds are faster than poly and mask divisions and modules
Comments
Post a Comment