title: Examples of problems whose solution can only be recursion
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/931762/can-every-recursion-be-converted-into-iteration">Can every recursion be converted into iteration?</a>  </p>
  </blockquote>
  
  
  
  <p>Are there problems in which one must use recursion and there is no way to do it iteratively ? For instance deleting the files within a sub-folder's .</p>
  
  <pre><code>public static boolean deleteFile(String sFilePath)
  {
    File oFile = new File(sFilePath);
    if(oFile.isDirectory())
    {
      File[] aFiles = oFile.listFiles();
      for(File oFileCur: aFiles)
      {
         deleteFile(oFileCur.getAbsolutePath());
      }
    }
    return oFile.delete();
  }
  </code></pre>
  
  <p>I can't think of an iterative version of the above one as we must be knowing before hand how many level of folders are actually there and if we introduce a new sub folder we'll have to change the code.Is it possible to make an iterative version of the above code in such a way that future code change won't be required ? </p>