i have following problem from book introduction algorithm second edition by MIT university
problem is following
An array A[1 . . n] contai
Here is a Python implementation:
def bit_at(n, bit):
return (n>>bit) & 1
def find_missing(a, bits):
indexes = range(len(a))
missing = 0
for bit in range(bits):
ones = [i for i in indexes if bit_at(a[i], bit)==1]
zeroes = [i for i in indexes if bit_at(a[i], bit)==0]
if len(ones) <= len(zeroes):
indexes = ones
missing |= (1<