c++ - recursion without base case and statements following recursion function -


when statements after recursion executed if there no base case ?

              void fun(int x,int y){                statement 1;                statement 2;                fun(x',y');                statement 3;                statement 4;                } 

here statement 1 , 2 not base cases.when statements 3 , 4 executed if every recursion sends control recursive function ?

my question in reference code https://ideone.com/lekxw5 .in link have given, when statement after line 24 or after recursion executed ?

             @ link of code before answering .                  void dfsbipartitecolor(int x, int y, int c)               {                // if got paint cell:                   if ( (board[x][y] == 'x') && (color[x][y] == -1) ) {                    // color it:                   color[x][y] = c;                    // special case: have foudn there @ least 1 x:     result = std::max(result, 1);      // try adjacent hexagons:     (int nx = max(0, x-1); nx <= min(n-1, x+1); nx++) {         (int ny = max(0, y-1); ny <= min(n-1, y+1); ny++) {             // hexagon adjacent , has x:             if ( (nx - x != ny - y) && (board[nx][ny] == 'x') ) {                 // continue dfs, negate color:                 dfsbipartitecolor(nx,ny, !c);//                  // special case: know there 2 adjacent x:                 result = std::max(result, 2);                 // if color not consistent, graph not bipartite:                  if (color[nx][ny] == c) {                     result = 3;                 }             }         }     } } 

when statements after recursion executed in code above ?

you have simplified code much, there condition:

void fun(int x,int y){     statement 1;     statement 2;     if(condition) fun(x',y');     statement 3;     statement 4; } 

so when condition not met, calls return.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -