Simple Recursion Quiz

May the 4th be with you!

In interviews, a software engineer is often asked to draw something on the board. One style of diagramming is a flow chart. Flowcharts are essential in a quality design processes.

A common type of solution software engineers must design is a recursive function – a function that calls itself to compute an answer to a given question. Interviewers want to know their hired developers are used to thinking this way.

Take for example, the following test:

Simple Recursive Function Quiz

It’s a simple test. It’s not designed to trip anyone up – but to see if the candidate has the knowledge to tackle this type of problem. Here is my simple solution:

Simple Recursive Function Solution

I hope this little exercise was of use to you.

Advertisements