times are hard, jobless numbers increase

I was rejected, by my own best friend, a man I would call “brother” (if we were related), for a job today.

Here’s the interview question posed:

1) The Fibonacci sequence is a well-known sequence of numbers which occurs frequently in natural processes. It is defined thus;

Fib[1] = 1

Fib[2] = 1

when n>2, Fib[n] = Fib[n-1]+Fib[n-2]

i.e., each term in the sequence is the sum of the previous two terms; and so the sequence starts 1, 1, 2, 3, 5, 8, 13, 21…

a) On the whiteboard, in whatever language you like (or pseudo code), write a recursive function to return the nth term in the sequence.

b) Write an iterative function to return the nth term in the sequence.
Can you say anything about the comparative speed / memory usage of each version?

My answer:

I’d just like to say that the recursive code I’d write would be tremendously slow when compared with the iterative version. But this is expected and whilst the code would look nicer, we should not, even in these days of incredible computing power, reject the more efficient iterative code simply because we like a tidy bush.

So do I get the job?

Sturge’s reply:

Purely for the use of the phrase “tidy bush”? Err, no, ‘fraid not.


3 Responses to times are hard, jobless numbers increase

  1. BigBlueSturge says:

    So, hang on, based on the question posed, it’s a fair assumption that one version or the other is significantly better than the other. You have guessed (correctly as it happens) which one is better and riffed on that guess for a while. You’ve then stuffed onto the end of your waffle the words “tidy bush” for no obvious reason and hoped that no-one will notice that you’ve not answered the rest of the question. Finally you’ve handed the whole thing in on foolscap paper and said “Gizza job”.
    I don’t think that your demonstrably extensive skill-set really meshes with our requirements matrix.

  2. BigBlueSturge says:


    • Alf says:

      Actually I have no idea what you’re talking about.

      I withdraw my job application with immediate effect.

      (And just so you know, I knew the recursive one would take longer cos we’ve discussed it in a previous episode on a Pubthursday).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s