Software Development Engineer In Test(SDET) Interview Questions | Glassdoor.co.in

# Software Development Engineer In Test(SDET) Interview Questions

55

Software development engineer in test(sdet) interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

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

26 May 2013
 Consider a stack of N number of cards which are piled up and in facing down. Each card has a unique number from the range 1 to N. The card is stacked in such a way that it exhibits the following behavior: Take the first card and put it under the stack without revealing. Now the next card on the top will have the number 1 on it. Next take 2 cards one after the other and put is under the stack without revealing. Yes you guessed it right - the next card on the top will reveal a value of 2. This goes on. Eg. for such a series : 9,1,8,5,2,4,7,6,3,10 [for N=10] Write a program to generate such a series for a given N number of cards so that this behavior can be exercised.8 AnswersPossible implementation in C++ -------------------------------------------------- int CounterStep(int counter,int N); int LocatePosition(int *cards,int N, int startPointer,int value); using namespace std; void main() { int cards; int N=20; int POS = 0,TOP = 0; // Initializing everything to zero for(int i=0;iWritten in Python although it can be re-written in C/C++ if required. def generateSpecialSeries(numberOfCards): specialSeries = [] if numberOfCards > 0: for i in range(numberOfCards, 0, -1): specialSeries.append(i) currentSpecialElement = 1 currentIndex = 1 while currentIndex < numberOfCards: indexOfCurrentSpecialElement = numberOfCards - currentSpecialElement specialSeries[currentIndex], specialSeries[indexOfCurrentSpecialElement] = specialSeries[indexOfCurrentSpecialElement], specialSeries[currentIndex] currentSpecialElement += 1 currentIndex += currentSpecialElement + 1 return specialSeries specialSeries = generateSpecialSeries(50) print specialSeries specialElement = 1 specialElementSum = 1 currentIndex = 1 while currentIndex < 50: print specialSeries[currentIndex] == specialElement specialElement += 1 specialElementSum += specialElement currentIndex += specialElement + 1// Short and simple C++ algorithm #define N 10 void compute(int stack[]) // Make sure N elements are allocated { int j=0; for(int i=0; iShow more responses#include using namespace std; int main(int argc,char **argv){ int count=20; int array; for(int i=0;i>a; return 0; }Java implementation public class App { public static void main(String[] args) { String arr[] = new String; int pointer = 0; for (int valueToPlace = 1; valueToPlace <= arr.length; valueToPlace++) { for (int x = 1; x <= valueToPlace; x++) { if (pointer == arr.length - 1) pointer = 0; else pointer++; if (arr[pointer] != null) x--; } System.out.println("Placing " + valueToPlace + " at index " + pointer); arr[pointer] = valueToPlace + ""; while (arr[pointer] != null && valueToPlace != arr.length) { if (pointer == arr.length - 1) pointer = 0; else pointer++; } } for (String str : arr) { System.out.print(str + ", "); } } }The algorithm used is: For each number n (ranging from 1 to 10), we have to skip n places in the array. And then put number n at that position. The catch in the program is that we can skip only, not occupied places (the array places where value is 0 by default). Also, when we reach the end of the array, we have to move back to beginning of array (similar to cards being kept at the bottom of the pile of cards.) Here, a variable 'pos' is used to store the final position of any element. Initially, pos is at 0. The skip() takes the array, the current value of pos and the number of skips to be made. For example, for n=1, the values passed to skip() would be: pos=0, n=1. This means that we have to skip 1 place starting from index 0. Similarly, for n=2, pos=1. This means we have to skip 2 places starting from index 1. Java Implementation: public class StackOfCards { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int[] arr = new int; int pos=0; for(int n=1;n0){ if(arr[pos]==0){ //reduce the number of skips to be made n--; } pos++; //if end of array is reached, take pos back to beginning if(pos==10){ pos=0; } } // keep incrementing pos until a not occupied index is reached. while(arr[pos]!=0){ pos++; } return pos; } }Here is C# Code... namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n = 36; int[] series = new int[n]; int LargestNumber = n; int SmallestNumber = 1, temp = 1, i; bool putLargeNumber = true; for (i= 0; i 0)) { series[i] = LargestNumber; Console.Write("{0} ", series[i]); LargestNumber = LargestNumber - 1; putLargeNumber = false; temp--; } else { series[i] = SmallestNumber; Console.Write("{0} ", series[i]); SmallestNumber += 1; putLargeNumber = true; temp = SmallestNumber; } } } } }import java.util.HashMap; import java.util.HashSet; import java.util.Scanner; import java.util.Stack; public class MSQuestion1 { static int counter =1; public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n =in.nextInt(); // x 1 x1 x2 2 x3 x4 x5 3 x6 int[] arr = new int[n]; int f = 0; while(f0)) { arr[f]=counter; counter++; } f++; } for(int i=0;i

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

24 Mar 2012
 Sorting Algorithms Optimizations from 2 loops to just 1 loop5 AnswersNC#include #include using namespace std; int main() { int list = {5, 4, 3, 6, 7, 1, 2, 9, 8, 10}; for (int i=0; i= 0 && next list[next]) { int temp = list[i]; list[i] = list[next]; list[next] = temp; next--; } else next++; } } for (int i=0; i<10; i++) { cout << list[i] << " "; } return 0; }you still have two loops #include #include using namespace std; int main() { int list = {5, 4, 3, 6, 7, 1, 2, 9, 8, 10}; for (int i=0;j=i; i<10; i++;j++) { I can't remember, but you use two indices within one loop to sort using bubble sort } for (int i=0; i<10; i++) { cout << list[i] << " "; } return 0; }Show more responsesuse quicksort. it has runtime of O(n.logn), or heapsort. they both use one for loop and a heap/stackstatic void Main(string[] args) { int[] arr = new int[] { 8, 9, 6, 7, 4, 5, 2, 3, 1 }; int i = 0; bool swapped = true; while (swapped || i arr[i + 1]) { int temp = arr[i+1]; arr[i + 1] = arr[i]; arr[i] = temp; swapped = true; i=0; } else { i++; swapped = false; } } foreach ( int element in arr) { Console.Write("{0} ",element); } } } --------------------- contact.if.urgent@gmail.com

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

24 May 2012
 In a sequence of alphabets (like aaabbddaabbcc) write a program to find the number of the consecutive alphabets in and print the alphabet and number. example :if input is aaabbddaabbcc then output should be 3a, 2b, 2d, 2a, 2b, 2c4 AnswersI misunderstood the question, and wrote the program for printing number of a's or b's etc., present in the sequence when I showed him he asked me to code according to his requirement, the program should produce output without any errors,during this time he was writing something in the laptop. I wrote program correctly. He said ok.void PrintAlphaNum( string str ) { if ( (str == null) || str.Length == 0 ) { return; } char lastChar = str; int count = 0; foreach( char ch in str ) { if ( ch == lastChar ) { count++; } else { Console.Write("{0}{1}, ", count, lastChar ); count = 1; lastChar = ch; } } if ( count > 0 ) { Console.WriteLine("{0}{1}", count, lastChar ); } }#Iinclude #include main() { char str[ ]; printf("Enter the input\n"); scanf("%c",&str); printf("input:%c",str); int len= strlen(str); int alp; if(str!='NULL' && len!=0) { for(int i=0;iShow more responsesSimple Java Code: String str = "aaabbddaabbcc"; for(int i = 0; i < str.length()-1; i++) { int count = 0; for(int j = i; j < str.length(); j++) { if(str.charAt(i) == str.charAt(j)) count++; else { i += count - 1; break; } } System.out.print(Integer.toString(count) + Character.toString(str.charAt(i)) + ", "); }

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

22 Jun 2012
 in final 10 min he give me problem to find median of two shorted arrays2 Answerscould not answerarray1  = {1,3,7,10,11} array2 [4 ]= {2,4,5,6} position of median will be=(5+4)/2=4(floor value) now,simply check whether which of the two,array1[4/2] or array2[4/2] is smaller. time complexity: O(1) Considering that size of the 2 arrays was known prior..!

### Software Development Engineer In Test (SDET) II at Expedia Group was asked...

5 Jun 2013
 Remove all characters of a string from another string. The algorithm should be less than O(m*n) where m & n are lengths of strings and the space used should be less than O(m+n).3 AnswersI have written a program using Hashmap and StringBuilder.An efficient solution to the problem can done using simple pattern matching. A sample solution goes as follows : public class SampleMain { /** * @param args */ public static void main(String[] args) { String charStream = "ABABCBABABABABABATGBHacbfoabcbahasacbJKOPLMNBGDESRABADACAJALAMNBADDHEMSZPQ"; String noise = "ABCPQR"; System.out.println("CharStream : " + charStream + "\n" + "Noise : " + noise + "\n" + "FliteredCharStream : " + func(charStream, noise)); } private static String func(String charStream, String noise) { String regex = "[" + noise.toLowerCase() + noise.toUpperCase() + "]"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(charStream); return m.replaceAll(""); } }import java.util.Arrays; public class Solution{ public static void main(String[] args){ System.out.println(remove("as","asasfsg")); } public static String remove(String s1, String s2){ boolean[] flags = new boolean; char[] a1 = s1.toCharArray(); char[] a2 = s2.toCharArray(); String str = ""; Arrays.fill(flags,false); for(int i=0; i=a1.length && i

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

26 Sep 2012
 given a linked list which has two types of pointers, a normal next pointer which points to next element in the list and random pointer which points to random element in the list. Question was to clone this linked list3 Answersthere is a solution in O(n) time@ Interview Candidate: can you give some details about the logic ?import java.util.HashMap; public class MSQuestion2 { public static void main(String[] args) { // TODO Auto-generated method stub CustomLinkedList lst = new CustomLinkedList(); lst.head=new Node1(1); lst.incrementsize(); Node1 node2 = new Node1(2); lst.head.next=node2; Node1 node3 = new Node1(3); node2.next=node3; lst.printList(lst); // lst.reverseList(lst); lst.printList(lst); CustomLinkedList clonelst= lst.clone(lst); lst.printList(clonelst); } } class Node1 { int data; Node1 next; Node1 random; public Node1(int data) { this.data=data; this.next=this.random=null; } } class CustomLinkedList { Node1 head; static int size; public CustomLinkedList() { this.head=null; this.size=1; } public CustomLinkedList(Node1 head) { this.head=head; this.size=1; } public CustomLinkedList clone(CustomLinkedList lst) { // TODO Auto-generated method stub CustomLinkedList lst2 = new CustomLinkedList(); HashMap map = new HashMap(); Node1 n = lst.head; Node1 clonednode = null; while(n!=null) { clonednode = new Node1(n.data); map.put(n, clonednode); n=n.next; } n = lst.head; while(n!=null) { clonednode=map.get(n); clonednode.next=map.get(n.next); clonednode.random=map.get(n.random); n=n.next; } lst2.head=map.get(lst.head); return lst2; } public void printList(CustomLinkedList lst) { Node1 n = lst.head; while(n!=null) { System.out.println(n.data); n=n.next; } } public void reverseList(CustomLinkedList lst) { Node1 n=lst.head; Node1 prev =null; Node1 next = null; while(n!=null) { next=n.next; n.next=prev; prev=n; head=n; n=next; } } public void add(CustomLinkedList lst,int data) { Node1 node= new Node1(data); node.next=null; size++; } public void incrementsize() { this.size++; } }

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

17 Dec 2009
 how to merge two linked lists without using temp node3 Answersyou can modify the lists to form circular lists. that both are merged to each other without temp.In case link lists are sorted, then per-form merge sort tech. otherwise above seems fineSuck my dick to know the correct answer..!

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

7 Jan 2012
 merge 2 sorted linked lists .2 AnswersAssuming the list are in ascending order public Node Merge(Node l1, Node l2) { if (l1 == null) return l2; if (l2 == null) return l1; Node root = new Node(); Node first = root; while (l1 != null && l2 != null) { Node swap = (l1.Data < l2.Data) ? l1 : l2; root = root.Next = swap; l1 = l1 == swap ? l1.Next : l1; l2 = l2 == swap ? l2.Next : l2; } root.Next = (l2 == null) ? l1 : l2; return first.Next; }Assuming the lists are sorted in asc: public void Merge(LinkList list1, LinkList list2) { Link current1 = list1.first; while(current1 != null) { int count = 0; Link current2 = list2.first; Link previous = list2.first; while(current2 != null) { if(current2.dData >= current1.dData) { count++; if(current2 == list2.first) { Link newL = new Link(current1.iData, current1.dData); newL.next = list2.first; list2.first = newL; } else { Link newL = new Link(current1.iData, current1.dData); previous.next = newL; newL.next = current2; } break; } previous = current2; current2 = current2.next; } if(count == 0) { Link newL = new Link(current1.iData, current1.dData); previous.next = newL; } current1 = current1.next; } }

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

22 Jun 2012
 first question was on addition of two very larg number then he ask which data structure i will use and he asked me to write the code . then he asked about different testcase possible 1 Answeri told him that i will use list then he asked me why i told him about limitation of array size but want to listen about the requirement of contiguous memory for array then he asked me write the code . then he asked about different testcase

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

12 Jul 2012
 Data structures and Algorithms related2 Answersplz tell me which type of question put up in interviewIam ready
110 of 55 Interview Questions