Yahoo Interview Question
Country: United States
Interview Type: Phone Interview
1. Have a file handler, (size_t) reminder & char *buffer(of size BUFF_SIZE) for each of the files.
2. Read file contents to buff1 & buff2
where, BUFF_SIZE1= BUFF_SIZE-reminder1
BUFF_SIZE1= BUFF_SIZE-reminder1
3. Remove newline from both the buffers and prefix last reminder chars (this may lead in buff length mismatch, so keep the extra chars of longer buff as reminder for next read).
3. Compare the formatted buffers
4. Go to step 2 with reminder1 & reminder2
We could consider using two BloomFilters here, one for each file.
- teli.vaibhav June 07, 2013And since BloomFilters are not 100% accurate. We could compare the resulting BloomFilters of both the files if they match close to say something like ~97% (value depending on the efficiency of the HashFunction) then we could say they are identical.
Please correct me if I'm wrong.