Microsoft Interview Question Software Engineer in Tests

  • microsoft-interview-questions
    0
    of 0 votes
    9
    Answers

    Find output of the following code

    int
    mingle(int a, int b)
    {
    int c = b/2;
    if (b<=1) { return a;}

    cout<<c <<endl;
    return a*(b-2*c) + mingle(a,c);

    }

    int
    main()
    {
    int i;
    for (i = 1; i<=5 ; i++) {
    cout<<mingle(i+1,i-1)<<endl;
    }
    return 0;
    }

    - Gangadhar on September 18, 2010 Report Duplicate | Flag
    Microsoft Software Engineer in Test C++



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

1
2

3

8

30
10
5

- Anonymous on September 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this is incorrect.
The answer is:
2
3
1
4
1
10
2
1
6

- 12rad on September 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

garda 1 no..sakka h...:)

- jai on November 12, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

2
3
1
4
1
10
2
1
6

- strezh on September 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I got this:
2
3
1
4
1
10
2
1
30

- venkatesh.sourav on September 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

2
3
1
4
1
10
2
1
6

- ramu kumar on September 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

M(2,0) = {2}
M(3,1) = {3}
M(4,2) = {1 , M(4,1)} = {1 , 4}
M(5,3} = {1 , 5 + M(5,1)} = {1 , 10}
M(6,4} = {2 , M(6,2)} = {2 , 1 , M(6,1)} = {2 , 1 , 6}

- Ankush Bindlish on September 30, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mingle 2
mingle 3
c = 1
mingle 4
c = 1
mingle 10
c = 2
c = 1
mingle 6

- Anonymous on February 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ya i also got 2 3 1 4 1 10 2 1 6

- laasya1991 on September 12, 2011 | Flag Reply


Add a Comment
Name:

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

Books

is a comprehensive book walking you through 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