Test Development Engineer Interview Questions | Glassdoor

Test Development Engineer Interview Questions

867

Test development engineer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Nov 5, 2012

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; }

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 at Amazon was asked...

Jan 26, 2012
 Coding question - given a binary tree, write code to count the sum off all siblings.3 AnswersNot sure if this works... value == null) return \$sum; \$sum = \$sum + \$tree->value; countSiblings(\$tree->left,\$sum); countSiblings(\$tree->right,\$sum); } ?>int totalNumberOfNodes(Node root) { if(root == null) return 0; return 1 + totalNumberOfNodes(root.left) + totalNumberOfNodes(root.right); }private int siblingCounter = 0; public int countSiblings(BinaryNode node) { if(node.element == null) { return siblingCounter; } else { siblingCounter++; if(node.right() != null) { countSiblings(BinaryNode right); } if(node.left() != null) { countSiblings(BinaryNode left); } } return siblingCounter; }

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 ...

Oct 3, 2012

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...

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 at Amazon was asked...

Feb 16, 2012
 Implement a Queue using 2 Stacks3 AnswersUntil the first de-queue operation, keep pushing one of the stacks, say stack1, for every enqueue operation. When you encounter the first dequeue operation, then pop stack1 into stack2. Now, pop stack2, to get the dequeued element. Henceforth, on every dequeue operation, pop stack2, and on every enqueue operation, push stack1. At some point, stack2 might become empty, but this brings you back to the first stage !Here is an idea: public class StacksQueue { private readonly Stack stack1 = new Stack(); private readonly Stack stack2 = new Stack(); private Stack dequeueStack; private Stack queueStack; private Stack secondaryStack { get { if (object.ReferenceEquals(queueStack, stack1)) { return stack2; } else { return stack1; } } } public StacksQueue() { queueStack = stack1; } public void Queue(T item) { int count = 0; while (queueStack.Count > 0) { secondaryStack.Push(queueStack.Pop()); count++; } queueStack.Push(item); for (int i = 0; i < count; i++) { queueStack.Push(secondaryStack.Pop()); } if (dequeueStack == null) { dequeueStack = queueStack; } queueStack = secondaryStack; } public T Dequeue() { if (dequeueStack == null) { throw new InvalidOperationException("Trying to dequeue from queue which is empty"); } T result = dequeueStack.Pop(); if (object.ReferenceEquals(dequeueStack, stack1)) { dequeueStack = stack2; } else { dequeueStack = stack1; } if (dequeueStack.Count == 0) { dequeueStack = null; } return result; } }Hi, here is a smart solution in java based on shan.phreak solution : class Queue { Stack stack1 = new Stack(); Stack stack2 = new Stack(); public void push(Integer value){ while (!stack2.isEmpty()){ stack1.push(stack2.pop()); } stack1.push(value); } public Integer dequeue(){ while (!stack1.isEmpty()){ stack2.push(stack1.pop()); } return stack2.pop(); } }

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

Nov 29, 2009
 Write a function to find the maximum sum of sub array where the array can have negative and positive numbers.4 AnswersDon't jump to the answer. As some of you noticed, the question has ambiguties. Ask questions to clarify the question. They would like you to solve the problem after understanding all the details so that you won't miss any edge cases in your solution. Hint: The answer is recursive.answer in java: int array[] ={1,2,3,-6,5,6,9}; table = new int[7][7]; int i, j; int localMax = -999999999; for(i = 6 ; i >= 0 ; i--) for(j = i ; j < 7 ; j++) { if(i == j) table[i][j] = array[i]; else table[i][j] = array[i] + table[i+1][j]; localMax = Math.max(localMax, table[i][j]); } System.out.println(localMax);In Python: def largest_segment(s): y = 0 z = 0 for i in range(0, len(s)): y = max(y + s[i], 0) z = max(z, y) return z Algorithm is O(n). Only works if the max value for an array containing all negatives is 0.Show More Responsesdef maxSumSubArray(inputArray): currentSum = 0 grandSum = 0 for i in range(len(inputArray)): if (currentSum + inputArray[i]) < currentSum: currentSum = 0 continue else: currentSum = currentSum + inputArray[i] if (grandSum < currentSum): grandSum = currentSum return grandSum
2130 of 867 Interview Questions