How to effectively visualize a recursive function?
<p>I'm currently in the process of teaching recursion in a programming class. I noticed how hard it is for my students to grasp the concept of recursion. Is there a nice way to visualize what the function does for the pedagogical purposes?</p>

<p>As an example, here is an R function for getting the n'th Fibonacci number:</p>

<pre><code>fib_r &lt;- function(n) {
    if(n &lt;= 2) return(1)
    fib_r(n-1) + fib_r(n-2)
}
</code></pre>

<p>Thanks.</p>