227

Software Development Engineer In Test Ii interview questions shared by candidates

Top Interview Questions

Sort: Relevance|Popular|Date
Software Development Engineer In Test (SDET) II was asked...3 October 2012

post order traversal of a Binary Search Tree Follow up Create a BST from this post order traversed array and write test cases for this function

Creating a BST from the post order traversal output would involve adding the nodes in reverse order of the post order traversal output. For example, if the post order traversal output was 2,4,3,20. I would insert in the following order: 20, 3, 4, 2. Can anyone confirm if this is correct? Less

package test; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; enum TraversalType { PREORDER, INORDER, POSTORDER; } public class ConstructTreeBack { static Node root = new Node(); static TraversalType traversalType; static void formSubTrees(List treeList) { List leftSubTree = new ArrayList(); List rightSubTree = new ArrayList(); Iterator it = treeList.iterator(); int rootNodeVal = root.getValue(); while (it.hasNext()) { int nodeVal = it.next(); if (rootNodeVal &gt; nodeVal) { leftSubTree.add(nodeVal); } else if (rootNodeVal treeList) { Node node = new Node(); if (traversalType.equals(TraversalType.PREORDER)) { if (null != treeList.get(0)) { node.setValue(treeList.get(0)); } if (null != treeList.get(1)) { node.setLeftNode(new Node(treeList.get(1))); } if (null != treeList.get(2)) { node.setRightNode(new Node(treeList.get(2))); } } else if (traversalType.equals(TraversalType.INORDER)) { if (null != treeList.get(1)) { node.setValue(treeList.get(1)); } if (null != treeList.get(0)) { node.setLeftNode(new Node(treeList.get(0))); } if (null != treeList.get(2)) { node.setRightNode(new Node(treeList.get(2))); } } else if (traversalType.equals(TraversalType.POSTORDER)) { if (null != treeList.get(2)) { node.setValue(treeList.get(2)); } if (null != treeList.get(0)) { node.setLeftNode(new Node(treeList.get(0))); } if (null != treeList.get(1)) { node.setRightNode(new Node(treeList.get(1))); } } return node; } public static void main(String[] args) { int rootNodeVal = 0; List treeList; /*PRE ORDER TRAVERSAL*/ Integer treeArrPreOrder[] = { 4, 2, 1, 3, 6, 5, 7 }; rootNodeVal = treeArrPreOrder; root.setValue(rootNodeVal); root.setRoot(true); treeList = Arrays.asList(treeArrPreOrder); traversalType = TraversalType.PREORDER; formSubTrees(treeList); /*IN ORDER TRAVERSAL*/ Integer treeArrInOrder[] = { 1, 2, 3, 4, 5, 6, 7 }; int rootIndex = 3; root.setValue(treeArrInOrder[rootIndex]); root.setRoot(true); treeList = Arrays.asList(treeArrInOrder); traversalType = TraversalType.INORDER; formSubTrees(treeList); /*POST ORDER TRAVERSAL*/ Integer treeArrPostOrder[] = { 1, 3, 2, 5, 7, 6, 4 }; rootNodeVal = treeArrPostOrder[treeArrPostOrder.length - 1]; root.setValue(rootNodeVal); root.setRoot(true); treeList = Arrays.asList(treeArrPostOrder); traversalType = TraversalType.POSTORDER; formSubTrees(treeList); } } Less

Reverse each word of the string without reversing the order of the words this is a test BECOMES siht si a tset

public class ReverseWordsInString { public static void main(String[] args) { System.out.println("&gt;"); } private static String reverseWords(String original) { if (original == null || original.isEmpty()) { throw new IllegalArgumentException("IP cannot be null or empty"); } final Pattern p = Pattern.compile("[a-zA-Z]"); final StringBuilder returnString = new StringBuilder(); StringBuilder temp = new StringBuilder(); for (int i = 0; i 0) { returnString.append(reverse(temp.toString())); temp = new StringBuilder(); } returnString.append(original.charAt(i)); } } if (temp.length() &gt; 0) { returnString.append(reverse(temp.toString())); } return returnString.toString(); } private static String reverse(String data) { StringBuilder ret = new StringBuilder(); for (int i = data.length() - 1; i &gt;= 0; i--) { ret.append(data.charAt(i)); } return ret.toString(); } Less

/// /// Recieve a string of words and returns the words reversed without changing the order. /// Here's my C# method: public static string ReverseWordsInSentence(string sentence) { char[] whiteSpace = " \t\n".ToCharArray(); string[] words = sentence.Split(whiteSpace); int count = 0; foreach (string individualWord in words) { words[count] = new string(individualWord.ToCharArray().Reverse().ToArray()); count++; } return string.Join(" ", words); } Less

public class ReverseString { public String stringReverse(String str) { if (str == null || str.length() = 0; i--) { sentence.append(word.charAt(i)); } sentence.append(" "); } return sentence.toString(); } public static void main(String[] args) { ReverseString obj = new ReverseString(); String test = "this is a test"; System.out.println(obj.stringReverse(test)); } } Less

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

I 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(""); } } Less

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 &amp;&amp; i Less

Q: By share screen, please create code to reverse each words in a sentence.

create code by split, looping, and reverse each words

There's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Tokopedia Software Development Engineer In Test (SDET) II experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews Less

The interviewer confused me like hell when describing the question. Every node of the tree has a pointer to its left most child. each node has a pointer to its next sibling. Its a BST. Find the smallest value in the tree.

He confused me like hell. He started with "given a tree find the first node". Then went on clarifying the question as I digged in. Less

The key in generic questions like this, is to make sure to cover the fundamentals. There's usually a back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Microsoft Software Development Engineer In Test (SDET) II experts on Prepfully? Really helps to get some real-world practice and guidance. prepfully.com/practice-interviews Less

how to reverse words in a string preserving the formatting

public void ReverseWords(StringBuilder sb) { if (sb == null) { return ; } String tempStr = ""; int start = -1; int end = -1; //"My na" for (int i = sb.Length -1; i &gt;= 0; i--) { if (sb[i] == ' ') { if (end != -1) { start = i + 1; // end = 4 // start = 3 while (start &lt;= end) { tempStr = tempStr + sb[start]; start++; } start = -1; end = -1; } tempStr = tempStr + sb[i]; } else { if (end == -1) { end = i; } } } if (end != -1) { for (int i = 0; i &lt;= end; i++) { tempStr = tempStr + sb[i]; } } Console.WriteLine(tempStr); } Less

Find out the number of connected cells in a 2D array

The key in generic questions like this, is to make sure to cover the fundamentals. There's usually a back-and-forth with the interviewer. Might be worth doing a mock interview with one of the Microsoft Software Development Engineer In Test (SDET) II experts on Prepfully? Really helps to get some real-world practice and guidance. prepfully.com/practice-interviews Less

Given a BST find the second largest element?

Since A binary search tree is arranged into subtrees such that, the left subtree contains the values which are less than the root node and the right subtree contains the values which are larger than the root node. So, the largest element will be the Rightmost element of the right subtree. And the SECOND largest element will be it's parent. int findSecondLargest(tree *root) { tree *ptr, *prevPtr; prevPtr = NULL; ptr = root; while( ptr-&gt;right != NULL) { prevPtr = ptr; ptr = prevPtr-&gt;right; } if (ptr-&gt;left == NULL) return (prevPtr-&gt;info) ; // if ptr is the rightmost leaf node, then return its parent node // else if it has a left subtree then return the rightmost node in the left subtree. prevPtr = ptr; ptr = ptr-&gt;left; while (ptr ! = NULL) { prevPtr = ptr; ptr = ptr -&gt;right ; } return (prevPtr-&gt;info) ; } Less

Node findSceondLargest(Node root) { // If tree is null or is single node only, return null (no second largest) if (root==null || (root.left==null &amp;&amp; root.right==null) return null; Node parent = null, child = root; // find the right most child while (child.right!=null) { parent = child; child = child.right; } // if the right most child has no left child, then it's parent is second largest if (child.left==null) return parent; // otherwise, return left child's rightmost child as second largest child = child.left; while (child.right!=null) child = child.right; return child; } Less

Most questions are around data structures. Also expect word puzzles, like write an algorithm to spell out actual numbers. E.g. 121 -&gt; "One Hundred and Twenty One".

Break it down into 0, 1-9, 10-19, 20-99, 100-999, 1000-9999, ect...

I created my algorithm by parsing through the number from the largest place down to the smallest place i.e. for 1234 I parsed starting from 1 then 2, then 3 and finally 4. I created a bunch of switch statements that took in the numbers and spelled out the numbers. I had to be sure that in cases where I had 11, for example, that I looked at the proceeding number or else it could be ten, eleven, twelve, etc. Less