Thursday, February 25, 2010

Microsoft Internship Test Questions

Today i attended the Microsoft's Internship test . Here i am posting the questions so it will be useful to you too..
It was a one hour long descriptive test with six questions. The first four carries 5 marks each and remaining two carries 10 marks each.

  1. You are given a character string . Write the algo to print the character with maximum occurence and print that number of occurence too.
    Eg: i am an hacker --> output should be 'a' 3 times
  2. Give the output of the following code:
    #include<iostream>
    using namespace std;
    
    int main()
    {
    int a=10,b=2;
    b=a+++a;
    cout<<b<<" "<<a"\n";
    return 0;
    }
    
  3. Give the pseudocode for finding the factorial of a given integer.Make sure that the number should be of atmost two digits.
  4. What is Early binding and Late binding.
  5. You are given with a tree. Write the algo to make sure that it is a binary tree.
  6. You are given with a software application to send an email. write the testcases to check the working of the software.
  7. (There was a picture here ..showing the working of email sender application.i cant waste time by drawing it.)

5 comments:

  1. hey what is the best way to solve the first problem ??? apart from the conventional way of solving it

    ReplyDelete
  2. @Shiram... i think it uses the Contains method :-p

    ReplyDelete
  3. @Shiriam... My idea is to start from the index 0, get the char and check the frequency and then remove all of them in the given string, and then again start the first index until the string has no content.

    e.g.

    Hellow

    I) [0]=H => count all 'H's, they are 1; now remove them
    ello

    II) [0] = e => count all 'e's, they are 1; now remove them
    llo

    III) [0] = 'l' => count all 'l's, they are 2; now remove them

    o

    .
    .
    .

    now we know that 'l' is the char with the most frequency

    ReplyDelete
  4. @Shiriam as the range of the integer value of char is known make an array of it with size equal to largest value ie 122 .
    now traverse the arrar, for char in given char array increment the value corresponding a[atoi(char)].now after traversing the whole array.you will get the frequency and value of each character in integer array

    ReplyDelete
  5. @peyman dont you feel this way you are increasing the complexity of this algorithm

    ReplyDelete