Re:Want a job working on mongoDB? Your first online intervie...
by amock on Saturday April 23, 2011 @03:57PM
(#2477434)
It seems like you'd be IO bound when scanning the array so using larger than machine precision integers shouldn't slow things down. Particularly since you know the number of bits you'll need beforehand.
Scan over the array accumulating two quantities.
If A is the missing value and B is the extra value, after doing the whole array P = B/A and Q = A-B. Therefore, A = Q/(1-P) and B = AP.You could conceivably compute P in log terms as well to make it a bit more stable if needed.