Microsoft Interview Questions
- 0of 0 votes
AnswersFind output of the following code
- Gangadhar September 18, 2010
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;
}| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ - 0of 0 votes
Answersimplement:
- Anonymous September 15, 2010
float evaluate(char* s)
for example:
input: "1+2.5" output: 3.5
output: "4-5*8+4/2" output: -34| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersYou have to determine whether a polygon contains a point( origin ) or not. Vertex of the polygon are given in cyclic order. Polygon can be convex or concave. Write code( most important part).
- Ankur September 10, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersTell me how these DS stored in memory?
- ritz September 07, 2010
Hashtables, Dictionary, Trees, Arrays, LinkLists| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Data Structures - 0of 0 votes
AnswersThere is a linked list of numbers of length N. N is very large and you don't know N. You have to write a function that will return k random numbers from the list. Numbers should be completely random.
- katheopaul September 07, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersGiven a file in which the data is stored in the form
- not required September 04, 2010
ABC
_DEF
_GEH
XYZ
_PQR
__STY
Construct an nary tree out of it in O(n) time such that DEF and GEH are the children of ABC and XYZ is the sibling of ABC, PQR is child of XYZ and STY is child of PQR. The spaces after the beginning of a line specify the relation of a node to its predecessors.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a string u have to remove all the duplicate elements from the string and place them at the end of the string.
- not required September 04, 2010
For Example for the string "abbccddacde"
the output is "abcdebcdacd".
see that abcde are the unique elements and the repeated elements are in the order in which appear in the original string.
Give an O(n) solution for this.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersI attended MS interview loop this week and I was asked the below question.
- c# September 04, 2010
Given a IP address as input, validate the ip address.
ValidateIp(string inpIP)
My answer-I validated the characters in the string and then implemented atoi function on each substring and verified for its value in the range of 0-255, I was also asked to assume that an IP can start with 0.
PS: I am not selected:(, not sure if the interviewer knew some other way and expecting me to say the same:)...| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersHi All,
- c# September 04, 2010
I attended MS interview loop this week, I was unable to get through, pissed off after seeing the beautifully madeup regret mail from the staffing consultant, I wanted to share a question and my answer...Beware of the answer as I am not selected:)
here it goes..
Given a text document as input with a set of strings, assume '\n' is the delimiter, print to the console strings grouped by anagrams.
vinay
naviy
inavy
tes
set
...
My answer:
1. sort all the strings and compare...interviewer was not happy with the time complexity of sorting all strings.
2. create a hashtable where the hashcode is generated using the characters in the string..I got the hash of each string by doing an Exclusive OR of each charcater in the string although i had the dbt if the Ex-OR of non anagrams can be same, this is the only other solution that came to my mind.
Any efficient ways of solving this??| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test - 0of 0 votes
AnswersHi All,
- C# September 04, 2010
I attended MS interview this week, I was unable to get through, but I wanted to share a question for which i failed to give a efficient implementation..any ideas here..
here it goes...
Implement a firewall
prototype:
bool firewall(string url, list<string> IncludedList, List<string> ExcludedList)
Return true if the url is in included list
Return false if the url is in excluded list.
In a ambiguous situation return true\false based on best match.
Included\Excluded Url can contain '*' ex *.com, *.test.com etc...
if input url is www.test.server.com
IncludedLIst contains *.com and if ExcludedList contains *.test.com
Bestmatch in included is .com less then Bestmatch in ExcludedList .test.com..In this case it has to return false..| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersPrint all edge nodes of a complete binary tree anti-clockwise.
- Mahesh September 01, 2010
That is all the left most nodes starting at root, then the leaves left to right and finally all the rightmost nodes.
In other words, print the boundary of the tree.
Variant: Print the same for a tree that is not complete.
(I traversed the tree twice, but interviewer said there is a recursive way to solve this)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersQ) There is a document containing lots of information. You have a function char * getNextWord() which returns the next word from the document.
- Anonymous August 29, 2010
a) which data structure should be used for maintaining the information about the frequency of words.
b) Write an effective algo for maintaining the information about the frequency of each word in the document.
c) what is the complexity of algorithm.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersQ. There is an array
- Anonymous August 29, 2010
A[N][M] =
1 2 3
4 5 6
The array is rotated so that
A'[M][N] =
3 6
2 5
1 4
is obtained.
Establish the relation between A and A' by using i, j, M, N
A[i][j] = A'[_][_]| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 0of 0 votes
AnswersQ. There are two linked list that are sorted. We need to merge these lists so that the obtained list is also in sorted order. You should not prepare an extra list for merging the lists.
- Anonymous August 29, 2010
The next question was to write the test cases for testing the program.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C C++ - 0of 0 votes
Answersint main() { int i = 32242; int k = find(i); return k; } int find (int j) { if (j > 0) { j = j%10 + find(j/10); printf(" %d ", j); } return j; }
Find the output of the program?
- Anonymous August 29, 2010
Ans: 3 5 7 11 13| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C C++ - 0of 0 votes
Answerscreate your own atoi()?
- surath August 23, 2010| Report Duplicate | Flag | PURGE
Microsoft Algorithm - 0of 0 votes
AnswersGiven a statement which took an integer, incremented it by 1 and then branched to another location which you provide, implement addition of two numbers multiplication, etc using just that statement (or command).
- Anonymous August 23, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersDesign a parking garage. We spent a lot of time deciding whether Park() method should be in Car class or Garage Class. Any idea?
- Anonymous August 20, 2010
Now suppose that the parking rate depends on the date and time. How will you store this information?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersGive an algorithm to compress a memory. To be more clear if you are given a memory of some stored data here and there and some empty and null memory in between, how will you fragment and compress your memory?
- Meenu August 19, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersThere is a byte array which contains the character of one byte and two bytes. One byte character has range 0 to 127 and first character of 2 byte character is 128 to 255 and second byte character has range 0 to 255. Now, two pointers are given, one points to the start of the and another points to somewhere else.
- talk2arpit August 16, 2010
Tell which character 2nd pointers points to?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersImplement Stack with Push() Pop() and Mininum() operation in O(1).
- talk2arpit August 16, 2010| Report Duplicate | Flag | PURGE
Microsoft unknown Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a code to implement the Sodoku problem.
- Neetu August 12, 2010
Lets say you have a matrix of 9*9 and i can have valued from 1 to 9.
the rules are as below:
1. all the 3*3 matrix shouldn't have any duplicate number.
2. all the rows and columns can't have duplicate numebers.
3. all the diagonal elements in the 9*9 matrix can't have duplicate number.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding - 0of 0 votes
Answersyou have given a node of a tree. that node is defined as below:
- Neetu August 12, 2010
node(
int value,
node left;
node right;
node grandparent)
at the starting the grand parent node is null in the tree. you have to assign the grandparent node for all the nodes in the tree.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Data Structures - -1of 1 vote
Answers4th interview with the HR guy:
- S August 12, 2010
Asked me about the desired salary.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Behavioral - 0of 0 votes
Answers3rd interview: You are in a maze(like a labyrinth), and you open your eyes so you don't know your position. The maze has walls and you can move only in up, right, left and down directions. You can escape the maze when you find a ladder.
- S August 12, 2010
The following API is given:
bool TryMove(direction) - returns true when you don't hit a wall;
bool HasLadder() - return true if you found the ladder.
Write a method bool Explore() that returns true if you can escape the maze, false otherwise. Also, provide test cases.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
Answers3rd interview:Given a 4x4 board with pieces in it, find if the board has 4 identical pieces. Each piece has a shape and a color. Two pieces are identical if have the same shape and color. The pieces for this board have 6 colors and 6 shapes.
- S August 12, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
Answers2nd interview:Given a MxN matrix, in how many ways can you go from top-left to bottom-right?
- S August 12, 2010| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer