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. call tree <code>foo(n)</code>


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -