Microsoft Interview Report
- 1of 1 vote
AnswersWrite code to sort an integer array of size N which has only three unique values 0,1,2 duplicated & randomly placed over the entire array.
- yakku October 22, 2012 in India
- Memory used should be O(1)
- Run time should be O(N)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersWAP to print the node values of a binary tree
- yakku October 22, 2012 in United States
- Even level starting from right to left
- Odd level starting from left to right
Assume that level of root is 1.
a
b c
d e f g
Output: a c b d e f g| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 1of 1 vote
AnswersAssume that a binary tree is drawn over a Cartesian coordinate system (with X & Y axis) where the leftmost node is placed at point (0,0). So, we need to traverse the nodes and print in following manner:
- yakku October 22, 2012 in India
For e.g., for this tree
a
b c
d e f g
Output should be:
d,0,0
b,1,1
e,2,0
a,3,2
f,4,0
c,5,1
g,6,0| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - 0of 0 votes
AnswersAssume you have a integer matrix (m x n) sorted over column wise & row wise. WAP to find the kth smallest element from the matrix.
- yakku October 22, 2012 in India
E.g.
int[][] a =
2, 5, 8, 10
4, 7, 9, 12
6, 15, 20, 22
So 5th smallest element is: 7| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm