Recursion vs iteration with regards to memory usage
<p>Suppose I have a recursive as well as an iterative solution (using a stack) to some problem e.g. preorder traversal of a binary tree. With current computers, <strong>memory-wise</strong>, is there an advantage to using the recursive solution over the iterative version or vice versa for <strong>very large</strong> trees? </p>

<p>I'm aware that for certain recursive solutions where sub-problems repeat, there are additional time and memory costs if recursion is used. Assume that this is not the case here. For example,</p>

<pre><code>preOrder(Node n){
    if (n == null) return;
    print(n);
    preOrder(n.left);
    preOrder(n.right);
}
</code></pre>

<p>vs</p>

<pre><code>preOrder(Node n){
    stack s;
    s.push(n);
    while(!s.empty()){
        Node node = s.pop();
        print(node);
        s.push(node.right);
        s.push(node.left);
    }
}
</code></pre>