Does bitset optimize time ? or memory only?
Let there is an array ara[n] and a bitset a , both has size n. . if we access the array with a for loop as for(int i=0;i<n;i++)ara[i] the complexity is O(n). Now if we access the bitset as for(int i=0;i<n;i++)a[i] then what is the complexity? O(n) or O(n/32)??
Complexity is O(n). What is bitset? This is array of (n + 31) / 32
uint32_t
items or (n + 63) / 64uint64_t
items.set / unset / get operations:
Your cycle equivalent to:
But XOR, AND, SHIFT and other require ≈ N / 64 operations