Interviewing Software Engineers
Technical interviews have been addressed repeatedly by noted gurus and usual suspects, but many of the sorts of questions I like to ask have yet to surface. I like to ask questions that reveal many levels of insight. Some of the best questions I know involve asking candidate engineers to improve code. These questions don't have a single right answer, but rather these questions have many answers and tend to indicate the degree of an individual's insights and experiences.
For example, and this is just a quickly rolled example to make a point, one might ask a candidate to optimize the following function working from the assumption the compiler will perform no optimizations.
This function calculates a bitonal histogram of an image thresholding upwards at 128 and above.
void binary_histogram(unsigned int sum[2], const unsigned char* base, int rows, int cols)
{
    sum[0] = sum[1] = 0;
    for(int y=0; y < rows; y++)
    {
       for(int x=0; x < cols; x++)
      {
          const unsigned char* row = base + y*cols;
          if (row[x] < 128)
             sum[0] = sum[0] + 1;
          else
             sum[1] = sum[1] + 1;
          }
       }
}
Some candidates will move the pointer calculation to the outer loop. Others will eliminate the multiply altogether. Others will see there's no point to having two loops. Others will use a bit hack to index sum. Others will unroll the loop.
You get the picture.
A good follow-up question tests a candidate's knowledge of which optimizations modern compilers will do automatically.
Most candidates come up with something, which helps mitigate some of the typical awkwardness of technical interviews.
Anyhow, I hope this demonstrates the general idea and leaves you with a challenge: Devise the best questions you can to test levels of experience and insight.
For example, and this is just a quickly rolled example to make a point, one might ask a candidate to optimize the following function working from the assumption the compiler will perform no optimizations.
This function calculates a bitonal histogram of an image thresholding upwards at 128 and above.
void binary_histogram(unsigned int sum[2], const unsigned char* base, int rows, int cols)
{
    sum[0] = sum[1] = 0;
    for(int y=0; y < rows; y++)
    {
       for(int x=0; x < cols; x++)
      {
          const unsigned char* row = base + y*cols;
          if (row[x] < 128)
             sum[0] = sum[0] + 1;
          else
             sum[1] = sum[1] + 1;
          }
       }
}
Some candidates will move the pointer calculation to the outer loop. Others will eliminate the multiply altogether. Others will see there's no point to having two loops. Others will use a bit hack to index sum. Others will unroll the loop.
You get the picture.
A good follow-up question tests a candidate's knowledge of which optimizations modern compilers will do automatically.
Most candidates come up with something, which helps mitigate some of the typical awkwardness of technical interviews.
Anyhow, I hope this demonstrates the general idea and leaves you with a challenge: Devise the best questions you can to test levels of experience and insight.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home