Facebook Interview Question: For a given set of software c... | Glassdoor

Interview Question

Production Engineer Interview Menlo Park, CA

For a given set of software checkins, write a program that

  will determine which part along the branch where the fault lies.

Interview Answer

4 Answers


first, design a test case to detect the failure.
next, determine the last known "good" state of the software, i.e. the revision number of the last known "good" state.
now, write a script that will check out each subsequent revision starting from the known good revision, build, run the test case and examine the output.
When output fails, you can determine the revision at which the bug was introduced.

Anonymous on Nov 28, 2012

A - array of versions, |A| = n
check(A[0]) = true - first version is fine
check(A[n-1]) = false - last version has the fault

binary search:

int start = 0;
int end = n-1;
 int middle = (end+start)/2;
 if (check(A[middle])) start = middle;
 else end = middle;

A[end] is the version with the fault

Anonymous on Feb 7, 2013

I would write an integration test, for that scenario which started to fail. Then I'd write a shell script which would run that test over some amount of last revisions. Once test is failed, you've found a revision where mistake was made.

holms on Aug 19, 2013

Don't forget to consider how long the code takes to fail. If it takes a significantly longer time to fail than to succeed start with the last known good version and work towards the most recent version. Depending on how costly it is to test doing a binary search may be the best option in cases where there is no significant time difference between success and failure.

timmy on Nov 4, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.