Software Engineer In Test Interview Questions | Glassdoor

# Software Engineer In Test Interview Questions

1,281

Software engineer in test interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

Sep 3, 2010

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Nov 5, 2012

Mar 18, 2009
 Design a function which returns the number of set bits in a given number, when expressed in binary4 Answersint numBits(int num) { int numBits = 0; while(num > 0) { if(num % 2) numBits++; num /= 2; } return numBits; }The question stipulates "a number", but the code assumes "a positive integer". (It also assumes the number expressed in binary has a C compiler's default number of bits for type int (e.g. 32); that's probably acceptable since a real-world case would likely specify that type. ) Consider: /* return n of set bits in a signed int */ int numBits(int num) { int numBits = 0; while (num != 0) { if (num < 0) ++numBits; num <<= 1; } return numBits ; }You may get faster results with some precomputing... /* lookup table with number of bits set per byte */ const short lookupTable[256] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, ... }; int numBits(int num) { unsigned char *p = (unsigned char *)# // not necessarily required, but makes for easier reading return lookupTable[p[0]] + lookupTable[p[1]] + lookupTable[p[2]] + lookupTable[p[3]]; // assumes 32 bit integer }Show More ResponsesUse a logarithm, base-2. def num_bits(n): return int(math.log(n, 2) + 1)

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Apr 14, 2009
 Code a function in C to get the largest consecutive addition of integer numbers fron an array.3 Answers/* Haven't done C in a while, so pardon me. * Essentially, you have to use dynamic * programming (see Wikipedia entry on the * subject if you are unfamiliar). Create * a table where one dimension represents * where we start summing ints, and the * other dimension represents where we end * summing ints. Because not all table * entries will be valid, we'll only be * filling half of the table. */ #define MAX(a,b) ((a) > (b) ? (a) : (b)) int largest_sum(int array[]) { /* Create our memoization table */ int max_sum = INT_MIN, i, row, col; int array_size = sizeof(array) / sizeof(int); int **mem_table = (int**)malloc(array_size * sizeof(int*)); for (i = 0; i = column are * nonsensical and are ignored. */ for (row = 1; row < array_size; ++row) { for (col = row; col < array_size; ++col) { mem_table[row][col] = mem_table[row][col-1] + array[col]; max_sum = MAX(max_sum, mem_table[row][col]); } } return max_sum; }Blech, that's what I get for posting code without testing it first. Sorry about the double-post; wish I could edit my entry. int largest_sum(int *array, int array_size) { /* Create our memoization table */ int max_sum = INT_MIN, i, row, col; int **mem_table = (int**)malloc(array_size * sizeof(int*)); for (i = 0; i = column are * nonsensical and are ignored. */ for (row = 0; row < array_size - 1; ++row) { for (col = row + 1; col < array_size; ++col) { mem_table[row][col] = mem_table[row][col-1] + array[col]; max_sum = MAX(max_sum, mem_table[row][col]); } } return max_sum; }best = 0; current = 0; for (int i=1 to n) { current = MAX(current + array[i], array[i]) best = MAX(current, best) } return best; Complexity O(n), additional memory used O(1) Proof: MaxSuffixSum(empty) =0 MaxSuffixSum(a[1..n]) = MAX(MaxSuffixSum(a[1..n-1]) + a[n], a[n]) where MaxSuffixSum is a largest sum of numbers from some i to n. The largest consecutive sum is some suffix, so it is enought to calculate best suffixes ending at all indexes in the array and pick the best one.

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Jan 13, 2012
 Check if tic-tac-toe has a winner4 AnswersTic-Tac-Toe is game like soduku or checkers that is represented as having columns and rows which translates as a 2 Dimensional array. In this case a 3x3 array. Represented as [0][0] [1][0] [2][0] You would therefore permutate each possibility. .... ..... ...... ...... ..... ..... [2][2]It's all about state. You can only win on the placement of a token so check the possible ways to win from this position. So say the user places a value in the bottom left corner. Then you need only check the vertical, horizontal and the diagonal from this position. From the center position you will need to check 4 different positions (+ and x). This retains a O(1) solution but then again this only works if you can keep count of how many moves have already occurred.@Matt: I like your approach, but still question in doubtful. We have final state of game or we have to write decision function after every move?Show More Responses@VIctor.. It does not matter that we have final state or not we need to check with every input from users..and probably the check function gonna check on 8 places ...

### New Graduate - Software Development Engineer In Test at Microsoft was asked...

Nov 26, 2012
 You are in a room by yourself and someone walks into the room, asks you to find the temperature, and leaves. How would you find the temperature in the room without leaving the room?3 AnswersCall a friend to bring a thermometer over.Cut a 5cm*5cm*5cm ice cube from the refrigerator, and test how long it take for it to melt completely.Find two equal size ice cubes, for the first one, wait till it melts completely(0 ℃) , heat it till it boils, record the time t1. For the second one, wait long enough till the water has the same temperature with the room, than heat it till it boils, record the time t2. The room temperature is 100*t2/t1.

### Software Development Engineer In Test (SDET) at Microsoft was asked...

May 31, 2012
 reverse a linked-list3 Answerssimple declare 2 temperary variables and store the links of the variables of link list sequencially and alter the links make 1st link null.you'll need 3 pointers hereYou will need 3 pointers and iterate through the list, then reverse each element

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Feb 28, 2013
 Write a program takes in a string and a delimiter, and uses that delimiter to split a string and then will reverse the characters in every word (or jumble of characters between the delimiters), stuffing them back into a string when finished. ('The dog walks' becomes..... 'ehT god sklaw')4 Answersin C# static string ReverseStrings(string original, char splitter) { if (string.IsNullOrEmpty(original)) return null; int currentSplitIndex = -1; int p1 = 0, p2 = 0; while (p2 < original.Length) { while (p2 < original.Length && original[p2] != splitter) p2++; if (p2 < original.Length) //p2 points to separator { Reverse(ref original, p1, p2 - 1); p1 = ++p2; } } return original; } static void Reverse(ref string org, int start, int end) { for (int i = start; i <= start + (end - start) / 2; i++) { var c1 = org[i]; var c2 = org[end - i + start]; org = org.Remove(i, 1); org = org.Insert(i, c2.ToString()); org = org.Remove(end - i + start, 1); org = org.Insert(end - i + start, c1.ToString()); } }public void ReverseEachWordOfString(string orignal, char del) { int errorCode = 0; List list = SplitString(orignal, del, out errorCode); if (errorCode == -1) { Console.WriteLine("Empty string provide, Please provide valid input"); } else if (errorCode == -2) { Console.WriteLine("Empty delimiter provide, Please provide valid input"); } else { StringBuilder strbld = new StringBuilder(); char[] revString; foreach (var item in list) { revString = new Char[item.Length]; for (int i = 0, j = item.Length - 1; i SplitString(string orignal, Char del, out int errorCode) { errorCode = 0; List list = new List(); if (orignal == null || orignal == string.Empty) { errorCode = -1; return null; } if (del == null) { errorCode = -2; return null; } StringBuilder str = new StringBuilder(); for (int i = 0; i < orignal.Length; i++) { if (orignal[i] == del) { list.Add(str.ToString()); str.Clear(); } else { str.Append(orignal[i]); } } return list; }using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Reverse_Words { class Program { static void Main(string[] args) { string revString = string.Empty; string bufferString = string.Empty; string inputString = ""; // Checking input if (string.IsNullOrEmpty(inputString)) { Console.WriteLine("Input is empty"); inputString = Console.ReadLine(); } // Asuming word is set of leters and not include any other chars like "-" or "'" for( int i = 0; i = 65) & (Convert.ToByte(inputString[i]) = 0; i--) { outString += wordString[i]; } return outString; } } }Show More Responsesdef splitReverseString(inputArray,delimeter): tempArray = [] tempElement = '' if len(inputArray) == 0: return 'Null String' for i in range(len(inputArray)): if (inputArray[i] != delimeter): tempElement = tempElement + inputArray[i] else: tempArray.append(tempElement) tempElement = '' tempArray.append(tempElement) for j in range(len(tempArray)): tempElement = '' temp = tempArray[j] for k in range(len(temp)-1,-1,-1): tempElement = tempElement + temp[k] tempArray[j] = tempElement return tempArray

### Software Development Engineer In Test Intern at Microsoft was asked...

Apr 21, 2012
 You have a building with 100 stories. You also have two glass balls. You can drop the glass balls as many times as you want before they break. How can you find the floor at which they start breaking with the fewest number of drops? 3 AnswersNot truly a brain teaser because the answer is mathematical.If you have N stories, you use the first glass ball to increment by sqrt(N) stories. Once that ball breaks, you use your second to go to the level of sqrt(N) below where it broke, and increment floor by floor. You know it must break somewhere in that group of sqrt(N) stories. I believe this method gets you a runtime of O(n^0.5).search for "two egg problem". its a minimization of maximum regret problem http://www.datagenetics.com/blog/july22012/index.html

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Oct 7, 2010
 Write a function to turn a string into an integer and test it3 AnswersCString csNum; int nNum = 2; csNum.format("%d", nNum);oops wrong one CString csNum = "1"; int nNum = atoi(csNum);public int AtoI(string str) { bool isNeg = false; int index = 0; if (str[0] == '-') { isNeg = true; index++; } int result = 0; // "123" 123 // 1 * 10 + 2 12 * 10 + 3 int multiple = 1; int number = 0; for (int i = index; i < str.Length; i++) { number = str[i] - '0'; result = result * multiple + number; multiple = 10; } if (isNeg) { result = result * -1; } return result; }
3140 of 1,281 Interview Questions