question about missing element in array

Posted by davit-datuashvili on Stack Overflow See other posts from Stack Overflow or by davit-datuashvili
Published on 2010-05-31T21:35:03Z Indexed on 2010/05/31 21:43 UTC
Read the original article Hit count: 206

Filed under:
|

i have following problem from book introduction algorithm second edition by MIT university

problem is following

An array A[1 . . n] contains all the integers from 0 to n except one. It would be easy
to determine the missing integer in O(n) time by using an auxiliary array B[0 . . n]
to record which numbers appear in A. In this problem, however, we cannot access
an entire integer in A with a single operation. The elements of A are represented
in binary, and the only operation we can use to access them is “fetch the j th bit
of A[i],” which takes constant time.
   Show that if we use only this operation, we can still determine the missing inte-
ger in O(n) time

please help

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about homework