Bloomberg LP Interview Question
Software Engineer / Developersis it necessary to do that indefinitely. can't we just check for some levels like:
test_stack_growth(int i)
{
int i = j;
printf("i: %p\n", &i);
i--;
if (i == 0)
{
return;
}
test_stack_growth(i--);
}
int main()
{
test_stack_growth(3); // check for 3 levels of recursion
return 0;
}
My point is why is it necessary to check indefinitely. Isn't only checking for 1/2 levels of recursion enough?
main()
- Sri June 08, 2009{
callme();
}
void callme()
{
int i=0;
printf("Current Address :%u", &i);
callme();
}
Prints the address infinitely. Each call to callme() creates a stackspace and the variables defined in the function are stored there. Print the value of variable. Call the method again, new stackspace is created , print the val again. You can see if the stack is growing up/down.