Some questions on recursion

  1. Why is the following recursive function unsafe?
    int recurse(int v)
    {
       return recurse(v);
    }
    
  2. Is the following version any safer?
    int recurse(int v)
    {
       if (v>6) return recurse(v);
       return v;
    }
    

Answers to these questions.


Back to notes on recursion.