Microsoft Interview Questions
- 5of 5 votes
AnswersGiven an array of 0s and 1s, find out:
- HauntedGhost March 05, 2013 in United States
1. all the subsequences where number of 0s = number of 1s
2. max length subsequence where number of 0s = number of 1s
Update:
We need to find subarrays, not subsequences. Sorry for the confusion.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 11of 11 votes
AnswersGiven a string, find whether it has any permutation of another string. For example, given "abcdefg" and "ba", it shuold return true, because "abcdefg" has substring "ab", which is a permutation of "ba".
- sg March 02, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test String Manipulation - 0of 0 votes
AnswersImplement print function given an integer without using the built-in print function
- J March 01, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Compiler - -1of 1 vote
AnswersWrite a script to compare two files.
- Abhi February 26, 2013 in India
One is primary file and other is secondary.
I need to check if secondary file contains each line of primary (may be in different order) and should not contain any extra data.
exmaple:
cat primary
abc
lmn
xyz
cat secondary:
cat secondary
xyz
abc
lmn
then in this case compare function should give true.
Note: file contains may be any thing like html or xml code or other.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Perl - 0of 0 votes
AnswersYou come to office install the latest build of internet explorer and find out that instead of the expected page explorer loaded a blank screen .. before discussing with developer what test you will like to conduct so that he can pin point the problem from your observation
- vik February 25, 2013 in United States for Internet Explorer| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Testing - 2of 2 votes
AnswersThere is an machine which can process any kind of fruit and produce packaged boxes … write test cases for that
- vik February 24, 2013 in United States for Internet Explorer| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Testing - 2of 2 votes
Answers'K' number of char arrays of different length are given, find Cartesian product of them in optimal way & give complexity. I used divide & conquer.
- ameyabap February 23, 2013 in India for AppeX| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
Answerswe have given a char array like “a1b2c3″ we have to convert this array to array like this “abbccc” .This has to be done in place as we have given that array has just enough space to hold the expanded array.
- nishu9101 February 20, 2013 in India
example:
1)input: a1b1c1
output:abc
length of array will be shortened.
2)input: a2b2c2
output:aabbcc
length of array will be equal to given array.
3)input: a3b4
output:aaabbbb
length of array will be greater than given array.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersConsider a system of n nodes numbered 1 to n. Each node has its id(1 to n) and a value associated with it say val. Now Every node has a send method send(int to , int val) and receive method int receive(int from).
- sowmya February 20, 2013 in United States
So if node 1 wants to send value , it does like this . send(1,val).
Using these two methods, write a distributed algorithm. Such that when the algorithm finishes, every node in the system knows the sum of the values of all the nodes in the system.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind an ancestor of given two node from a tree in O(n) time. The tree is binary tree.
- Jeff February 14, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
AnswersLet assume you have access full heap memory. Now design & write code malloc and free operation.
- Jeff February 14, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 2 votes
AnswersGiven an infinite sequence of integers which are repeated many times. WAP to print "beep" if an integer appears ODDth time else print "no beep".
- learner February 10, 2013 in United States
example: input: a[] = { 1,4,2,4,3,2,4}
output: beep, beep, beep, no beep, beep, no beep, beep
Space complexity - O(1)| Report Duplicate | Flag | PURGE
Microsoft Intern Arrays - 2of 2 votes
Answersswap alternate bits of a given number
- ruddermechanic February 07, 2013 in India
eg: n=5 (0101)
output: 10(1010)
n=8(1000)
output:4(0100)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 2of 4 votes
AnswersGiven a binary tree return the level with maximum number of nodes
- ruddermechanic February 07, 2013 in United States1 / \ 2 3 /\ /\ 4 5 6 7 / \ 8 9
| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersAppend the last n nodes of a linked list to the beginning of the list
- ruddermechanic February 07, 2013 in India
eg: 1->2->3->4->5->6
if n=2
5->6->1->2->3->4| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - -1of 1 vote
AnswersPrint the last n lines of a file in one iteration
- ruddermechanic February 07, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - -1of 1 vote
AnswersImplement Queue using stacks
- ruddermechanic February 07, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Stacks - 0of 0 votes
AnswersWrite a code to extract individual blocks from a given matrix....
- Honey February 02, 2013 in India
Eg: if we have a 4x4 matrix you need to extract 2x2 independent matrices and store them in 4 different arrays...
Given matrix:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
For the above matrix the output should be as follows..
Array1: 1 2 5 6
Array2: 3 4 7 8
Array3: 9 10 13 14
Array4: 11 12 15 16| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - -1of 1 vote
AnswersWrite some functions in c/c++ and then re-write the same function that can improve performance(cpu/memory etc) and explain why?
- dindin February 02, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft C++ - 1of 1 vote
AnswersWrite a function that gets a number n and prints out a random list
- fly123 February 01, 2013 in United States
of numbers 1..n to the screen. For example:
randlist(5) : 1 5 3 2 4
randlist(6) : 4 6 1 5 3 2
This should be truly random (uniformly spread) and with a O(n) complexity.
Every number should appear only once. Random(n) is given as a tool you can use to generate a
single random number between 1-n| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Coding - 1of 1 vote
AnswersGiven a binary tree, find a binary search tree which is a subtree of the given binary tree and has the largest size?
- Ashish January 31, 2013 in India
Note : Here size means the no. of nodes and the binary tree can have more than one B.S.T. as its subtree.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Trees and Graphs - 0of 0 votes
AnswersGiven two linked lists combine them in a way such that the resultant must contain the elements alternatively from one list and the other list?
- Ashish January 31, 2013 in India
For ex.
LL1 : 1->2->3->4
LL2 : 5->6->7
Result : 1->5->2->6->3->7->4
Also provide test cases for the algorithm ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersGive an algorithm which removes the occurrence of A and I from string ? The algorithm must be in-place.
- Ashish January 31, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer String Manipulation - 2of 2 votes
Answersimplement your own sizeof() operator..
- ishanimahajan7 January 29, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
AnswersHow OS decide how much memory is needed as virtual memory ? Max % of memory which can be available as virtual memory?
- savi January 27, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Operating System - 0of 0 votes
AnswersGiven a two dimensional matrix of booleans, there is a function that returns the number of "true regions".
A region is a group of True values aligned vertically or horizontally.T T <= 1 region T F T F <= 2 regions F T
Question 1: How would you test a function that solve this problem, but is written by another developer. How many tests cases do you see?
- hnrqbaggio January 24, 2013 in United States for Office
Question 2: Now write the code to solve this problem. What are the time and space complexities?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Arrays Data Structures Debugging Microsoft Testing - 1of 1 vote
AnswersGiven a string, find the start position of the largest block of repeated charactes.
- hnrqbaggio January 24, 2013 in United States for Office
After the solution, I was asked to write down as many test cases I could to test the function as if it was created by someone else.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Microsoft String Manipulation Testing - 1of 1 vote
AnswersGiven two arrays of ints that are sets, create a function to merge them to create a new set.
- hnrqbaggio January 24, 2013 in United States for Office
A set must pass on these three conditions:
- All values are positive
- Sorted
- Non-duplicates| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Arrays Data Structures Debugging Microsoft - 0of 0 votes
AnswersTell me if a array of integers is a set.
- hnrqbaggio January 24, 2013 in United States for Office
A set must pass on these three conditions:
- All values are positive
- Sorted
- Non-duplicates
After the first solution, I was asked about time and space complexity and to create 5 test cases for my function.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm Arrays Data Structures Debugging Microsoft - 0of 0 votes
Answerswrite a pseudo code to calculate
- MI January 24, 2013 in India
func(n) = 2*(func(n-1)+func(n-2)) in log(n) complexity.
Given:.func(1) = 1;func(2) = 3.
What is initial matrix because of factor 2.| Report Duplicate | Flag | PURGE
Microsoft