r*******n 发帖数: 51 | 3 I agree with you because we can assume that the x can't be larger than what
the register can load. The complexity of operation x&(-x) should be somehow
constant, I guess, because the operation & should be done in one clock cycle
but -x might depend on bit length. However, it doesn't matter because we treat
sub operation as a O(1) operation. In this sense, we can say x&(-x) is a O(1)
operation.
I am now just wondering that if I want to use popcount, the only way to do it
is using assembly, right? |
|