c++ - Multiple recursive calls -
i know recursive function , how can visualize every recursive call on top of stack. have no idea how think when function make multiple calls like
float foo(int n){ int = 0; for(int = 0; < n; i++) += 1; if (n > 2) return foo(n/2) + foo(n/2); // happens here? return a; }
shall think of 2 different stacks or best way visualize result?
as other answers mentioned, there 1 stack , recursive calls evaluated strictly in given order.
however, analysis purpose, can visualize entire call sequence tree.
Comments
Post a Comment