The question of the recursion mastery factor has cropped up a few times on the IBO computer science forum and if you are considering incorporating it into your dossier you need to bear these points in mind:
- Don’t include recursion unless it is appropriate. It should be used for quicksort, or for binary tree traversal, and that is about it. If you have any other use in mind, please ask me first.
- Don’t use recursion to implement a while loop, eg to keep asking the user for input until they type ‘x’. This is inappropriate and can actually cause a stack overflow.
- Don’t use recursion where an iterative method would be easier. The whole point of recursion is that it can provide very elegant solutions to what would otherwise be quite complicated procedures. If you don’t believe me, try traversing a binary tree iteratively.
- Even if you do use it for sorting, make sure that ‘sortability’ is a success criterion. Otherwise it can look like you’ve only included a sort to gain the mastery factor, and that is not really the point.