C
C
cbgx742014-02-28 19:39:50
Programming
cbgx74, 2014-02-28 19:39:50

How to find values ​​in a huge array?

This is the question I was asked at the interview, but unfortunately I was not ready for it:
1) There is a large array of values ​​presented in binary form
2) In this array, each value has a pair, the same value, and only one value does not have a pair
3) Values ​​enter the buffer, but the buffer is much smaller than the array (let's say only one value can be placed)
4) Find the value without a pair
I was given hints:
- use binary operations
- matrix trace Tell me
where to at least dig. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tadex, 2014-02-28
@cbgx74

XOR through the entire array - the output will be a lone element

D
Dmitry, 2014-03-01
@EvilsInterrupt

XOR is a trivial problem!!!
Let me ask you another one:
Write a recursive factorial function that will iteratively calculate the result.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question