1) Your CPU has the following math functions:
Integer: (32 bit)
Add, change sign, shift, and, or, xor, not, set bit, clear bit, load
Float:(8 bit exponent, 24 bit mantissa)
Integer to float, float to integer, add, subtract, multiply, divide
Write a very fast routine that will give a rough approximation of LOG.
The obvious answer would be to return which bit held the Most significant bit. This would be a loop that would likely average 16 cycles. On a similar machine I got the answer in a couple of cycles by converting the number to a float and extracting the exponent.
This is a case of being able to "think outside the box" and trade off precision for speed.
2) Using only integer math, write a routine that will output a running average (IIR filter) of a 16 bit input.
The quick way limits you to divisors that are powers of two, but use shifts and adds to get the numerator and use shifts to divide. Using this you could set the filter up to give you something like 7/16 old value + 9/16 new value.
This is looking for someone that has worked at a low enough level to understand that shifts are faster than divides, and who can trade off precision for speed. Extra points if they come up with a conversion from percentage (give a number from 1-99) to fractions by having a table which gives the numerator and denominator for the closest fraction.
3) What is the difference between a Peer review and a formal inspection.
A peer review is when the programmer walks someone through their code looking for problems. A formal inspection involves logging and keeping track of problems found, their severity and if/when they were fixed. This question is looking for a familiarity with the software quality process.
4) Write a checksum routine.
Look for a checksum algorithm which will catch common problems such as one bit always reading 1. It should also be fairly quick, using shifting, adding and masking rather than multiply and divide.
An alternative to this would be to say write a function to test a block of memory. This would be a longer question and I'd look for things like do they just detect errors or do the make a simple analysis of what they might be. What sort of pattern would they write into memory?
5) Write an example of a function header.
I went into this My missive on Writing Debuggable Software. I'm looking for something that will work as a spec to see if the function is working as well as something that another programmer can use as documentation if they want to use the function in other code.
6) How long would it take to write a control program to frob the twiddlies on a framminstaff? Defend your estimate.
This is looking for what process they use. Do they say:
Write code: 3 weeks? Or is it more like:
Learn about framminstaffs and how to frob the twiddlies: 2 days
Design algorithm: 1 week
Review and redesign: 2 days
Design code: 3 days
Review and redesign: 1 day
Debug: 2 days
Update documentation: 0.5 days
Or do they say: "It ought to take me half a day so double that and use the next larger unit of measure so it'll probably take two weeks"?
Last Updated 9/24/98