Bloomberg LP Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{
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.

- Sri June 08, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

is 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?

- Anonymous January 02, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void testStack(int* i){
int j=0;
if(&j>i) cout<<"increase"<<endl;
else cout<<"decrease"<<endl;
}

void main(){
int i=0;
testStack(&i);
}

- bbs59 June 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I remember a joke about heaps:

Guy 1: How to increase the heap size?
Guy 2: Eat more.

- Anonymous January 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

heap - dynamic(controlled) memory allocation, not scope dependent
stack - also means buffer, automatic memory allocation, scope dependent

- Neerav March 15, 2010 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More