|
|
|
|
|
by shaftway
2619 days ago
|
|
My question is about walking around a data structure. Most candidates choose to represent it with arrays. I agree with stepping through code being lame. If a candidate has tried to do some sort of boundary condition check and mentions a test that'd catch it, then I'll give them a pass. If a candidate just blows past the code without any attempt whatsoever to check that they're in bounds on an array, then I'll ding them for that. You have no idea how often I see code like... Node neighbor = data[x+1][y];
... without any check at all to see if x+1 is in bounds for data.The infinite loop in my question is fairly obvious (because it involves walking around a data structure iteratively). Candidates either see it right away and handle it as they solve, notice it halfway through and crowbar it awkwardly in, or don't notice it until asked to walk through a specific test case, or don't even notice it while walking through the test case. Ultimately, if the code looks correct to me, or even close (I mess up occasionally) then I'll just ask what cases they would test. |
|