Software testing Interview Questions
software testing interview questions shared by candidates
Top Interview Questions
Given a number find it is one less than the power of two. 15 AnswersThe question could have been a little more detailed, most of the guys who took up the test could not understand this immediately. Given a number N, XOR it with N+1 = powers of 2 will give all 0s @Anonymous. That's not true. 3 in binary is 11 and 4 is 100, if you XOR 011 and 100 you will get 111, not 000. I think you meant to say that all numbers will be 1s. Show more responses N xor (N+1) = 2*N + 1 If the least bit is 1, then it is equal to N less than power of 2 if ( n << 7 ) cout << "It is one less than power of 2" For example 1 - 0000 0001 3 - 0000 0011 5 - 0000 0101 7- 0000 0111 // the power of two is always has the first bit set to1 and rest all would be set to 0. And one less than power of 2 has all the bits set to 1 except the fist bit. for example 16 = 10000 and 15 = 01111 Now if you do bit operation & on 16 and 15, you get zero. Hence, below is the code. public boolean oneLessPowTwo(int num){ boolean b = false; if(n & n+1 == 0){ b = true; } return b; } the power of two is always has the first bit set to1 and rest all would be set to 0. And one less than power of 2 has all the bits set to 1 except the fist bit. for example 16 = 10000 and 15 = 01111 Now if you do bit operation & on 16 and 15, you get zero. Hence, below is the code. public boolean oneLessPowTwo(int num){ boolean b = false; if((num & (num+1)) == 0){ b = true; } return b; } A one line answer to this question is: -1 + 2 to the power of -2 - language binary string prefix + length of binary string for N In Python: 2**(len(bin(511))-3)-1 Simple one line in any language with a function to convert int to binary string. 8 anwer Just another option of doing this Boolean checkNumber(int inputNum) { int temp = 2 ; while(temp < inputNum) { temp = temp * 2 ; } if(inputNum == temp-1) return True; else return False; } can any1 say it clarly..wt is dz 15+01111?? can any 1 say it clearly? package amazonExcerise; import java.util.Arrays; import org.apache.jasper.tagplugins.jstl.core.ForEach; public class concatenationArrays { public static void main(String[] args) { int a[] = { 1, 3, 77, 78, 90 }; int b[] = { 2, 5, 79, 81 }; int c[] = new int[9]; int j = 0; for (int i = 0; i 4) { c[i] = b[j]; j++; } System.out.print(" " + c[i]); } Arrays.sort(c); System.out.println(""); System.out.println("Sorted Array"); for (int i : c) { System.out.print(" "+i); } j = 0; System.out.println(); System.out.println("Array A:"); j = 0; for (int i = 0; i = 5) { b[j] = c[i]; System.out.print(" "+b[j]); j++; } } } } Show more responses N is the number so (1< One or more comments have been removed. |
Assume a matrix of integers they are sorted in boh row and column vice .. how do u find a given number from the matrix in a optimal way? 10 AnswersLet the matrix is n*m matrix. Then O(n log m) solution is trivial (binary search in each row). There is a easy O(n+m) solution too. The idea is to start from upper right corner (mat[0][m-1]) and traverse toward lower left corner (mat[n-1][0]). On the way check each entry and depending on whether larger go left or down. If there is a solution you will find it on the way. Or you will arrive to a point where you can no longer move without going out of the matrix. Either way you will check at most O(n+m) entries thus the solution in O(n+m). I think it could be done even better than in O(n+m). Instead of starting at the upper right corner do a binary search on last column and find the biggest element that is still smaller than the given number. Say it's gonna be A[i, m-1]. Now we could throw away all rows up to an including i (since A[i, m-1] is larger than all of these elements) and the last column. Repeat everything for a smaller matrix of size (n - i, m - 1); To elaborate a little on dp's idea and add my take on it I would do a binary search on the last column to find the interval where the number is in. This interval will be one row within the matrix (assuming the value is not in the last column) and to find the interval should be O(log n). Then I would do a binary search on the row that remains which should cost O(log m). Combined that would be O(log n) + O(log m). Let me know what you guys think of this solution. Show more responses Anonymous, consider the matrix and you are searching for 9. Using this new algorithm we would look at rows 2 and 3 since 8 < 9 < 10 and completely miss 9 in the last row. (1 3 5 7) (2 3 6 8) (3 5 8 10) (6 9 11 12) dp, what do you do if the first element in the last column is already larger than the target? I.e. there may be no number that is smaller that the target. You could throw away that column, but that's it, I think. If so, the worst case becomes O(m). What if you did a binary search on the diagonal.... A better solution than O[log(mn)] is unlikely. An mxn array can be laid in memory as a m*n one dimensional array at its base form. So a matrix sorted by row and column simply means this mxn one dimensional array is sorted. A binary search will get you the result in O[log(mn)], that is the fastest solution available. How about this. for m columns - do binary range_search. As in, start with m/2 th column, if the number is in this range...col(0) O (log(m+n)) oops, there is a catch.... If the number is in a range, it can be in that column, or any of the columns towards left of it....and in some cases, if its in the range.. it can still be on any columns on right..... need to tweak a bit more. Ok writing this 3rd time , no one will see this but for the sake of it, Using radix sort Take 10 buckets and enter all numbers respectively. For example all numbers unit digit with 9 will in 9 number bucket. Just divide the given number (input) and into parts , using mod operator. And using the divided number"s unit digit find that index in the bucket. Tada . Radix sort way the. Linear search way to find the number Complexity O ( n ) Phew |
Data structures and Algorithms related 2 AnswersIam ready plz tell me which type of question put up in interview |
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[20]; int N=20; int POS = 0,TOP = 0; // Initializing everything to zero for(int i=0;i Written 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; i Show more responses #include using namespace std; int main(int argc,char **argv){ int count=20; int array[20]; for(int i=0;i>a; return 0; } Java implementation public class App { public static void main(String[] args) { String arr[] = new String[10]; 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[10]; 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 |
Test Automation Engineer at Oracle was asked...
Sort Binary Arrays - {0,1,0,1,1,1,0,0,0,1} 7 Answerspublic static void SortBinaryArrays(int[] Binary) { int[] sorrtedArray = new int[Binary.length]; int i = 0; for (int a : Binary) { if (a == 0) { sorrtedArray[i] = a; i++; } } for (int a : Binary) { if (a == 1) { sorrtedArray[i] = a; i++; } } for (int a : sorrtedArray) { System.out.print(a + " "); } } int [] a= {1,0,1,0,1,1,1,0,0,0}; int [] arr= new int[a.length]; int left=0; int right=a.length-1; while (left Show more responses public static void main(String[] args) { int [] a= {1,0,1,0,1,1,1,0,0,0}; int [] arr= new int[a.length]; int left=0; int right=a.length-1; while (left public static void main(String[] args) { int [] a= {1,0,1,0,1,1,1,0,0,0}; int [] arr= new int[a.length]; int left=0; int right=a.length-1; while (left int[] a={0,1,0,1,1,1,0,0,0,1}; int index=0; public static int[] sortBinaryArray(int[] a) { for(int i=0;i public static int[] sortBinaryArray(int[] a) { int leftptr=0; int rightptr=a.length-1; while(true) { while(a[leftptr]==0) { leftptr++; } while(a[rightptr]==1) { rightptr--; } if(leftptr One or more comments have been removed. |
The most surprising part was that i was even asked questions about the basic electronics in the interview round as my branch was ECE... 6 AnswersIn the aptitude round... we had two cut-offs.. one was sectional and the other was overall cut off. For this post be thoroughly prepared with C, C++, sql, DBMS, puzzles Hi... i want to know about the date of this interview, and how much time they take to give response after HR round?? This was interview was held on 22nd September,2013. They took about 3 days after the HR round to respond back. Show more responses Thanks.. i also gave hr interview on 22sep but havn't received their call till now. Does thi mean i am not selected??? or they will call me for 2nd batch after sometime??? any idea?? No idea... |
SDLC, what games have you played till now? Have you played any PS games or not. Difference between Regression Testing and Retesting. 5 AnswersHello friend. I attended the same drive in feb 2015 and still didn't hear anything from them. Interview process was same as you mention by a consultancy and at same location in bangalore. Request to User who Post: -Can u please tell me if you got selected or not. - How you fell about game testing carrer and I would like to have a word with you before I start. - Are you having experience in this field. - Is job profile is secured. Suggestions to Other users: - Interview questions are as expected * what games you like * why you want to be a game tester * Name some games you played. * it will be a stress atmosphere, can you handle. * Less play will be there, can you survive - Make sure you decide before you got into this field. - Its India, gaming jobs are not that secured it seems. As a gamer im still confused to change my carrer to QA in gaming or not. Please leave you comments and suggestions. Thank you Hey Hi. I was rejected from that interview because I didnt had experience with PS games, and had some skid marks in my knowledge on SDLC. If you havent heard from them, call your consultancy and asked about the result, sony will not call you as they didnt signed u up directly. About game testing as a job, man its a tedious job, as like others. But you will enjoy as you are a gamer. The games will be on PS4, PS-VITA etc. Somewhere I read that game testing is like watching a 30 min video again and again for 8 hours a day and for 3 months. If you can handle this example, game testing will be piece of cake for you. I tried to convince them, that I am a gamer and I was ranked 3rd in world's No-1 Counter Strike server. It will take max 30 mins to get my hands on PS console. But they didnt cared about the PC games. They wanted pure PS gamers, which most of lower middle class, or upper middle class cant afford. I dont know how they are expecting a PS player hunting for Job :p So hope for the best!!! Best of luck. Thanks a lot man. Today I got confirmation from the consultancy that I got short listed from SONY and they will process the Offer letter. Man im currently working as a Technical Support Engineer and getting good amount of money but Confused alot now. My problem is i dont know how much secure this "Game Testing profiles" are. Will this experience count outside .? Will it be under Sofrware testing. ? Man I asked many of my friends and they also blank in this situation. I also did some research in internet but didn't get much positive response on it. If any one can help me it would be great. want to know if Game testing profilfe is better than Tech support job or NOT.. Show more responses Question- Is Game Testing is better than Tech Support or not? I wud say in my opinion it is far better than tech support. Coz of following reasons. - Tech support experience count only for tech support - But game testing experience can give you job in any testing field. Because it has same process, which are being followed in Software Testing. With a more pleasant environment. (I would say dont think of leaving this company, you will not get opportunity like this) - Game testing is enjoyable, literary you wont be playing games as normal gamer, but in the mean time you will be playing games, which is near to your interest, rather than another job - Its Sony, so you will get great opportunity to grow. May be I got rejected for some reasons, but the interviewers decision is final and I should obey that. So I would say go for it, and congratulations :) And do help others by sharing your interview experience. Good luck for your career :) Thanks a million again for the advice. Feeling proud to be a SONY PlayStation Game Tester. Guys, anyone out there looking for some career options in gaming then go for it. Its far more serious than just playing. good luck and all the best. Thank you again Soheet. |
Test Engineer at Amdocs was asked...
unix questions were difficult.....sql was easy....choose your skill carefully...i choose c so they asked only c questions.... 2 Answerswhat is my question ? What type of questions on C? I too chose C. Im expecting a technical / PI call for 2 months now...I cleared written on 22 September :( still no clue about Tech/PI frm dem... |
String Palindrom, reverse words in a string, find longest substring in a string, duplicate characters in a string and print the count of it. 5 Answerspublic static boolean isPalindrome(String string) { String reverse =""; for(int i=string.length()-1;i>=0;i--) { reverse=reverse+string.charAt(i); } if(string.equalsIgnoreCase(reverse) { return true; } return false; } //* Using stack public static boolean isPalindrome(String string) { String rev=""; Stack stack = new Stack(); for(int i=0;i //Reverse Words In a String public static String reverseWords(String s) { String res=""; String[] string=s.split(" "); for(int i=0;i=0;i--) { rev=rev+string.charAt(i); } return rev; } Show more responses //*Counting duplicates public static int countDuplicates(String str) { char[] charArray = str.toCharArray(); Map hash_map = new HashMap(); for(int i=0;i entry:hash_map.entrySet()) { if(entry.getValue()>1) { count=count+1; } } return count; } //Reverse Words in String public static String reverseWords(String string){ String[] stAr=string.split(" "); String result=""; for(int i=stAr.length-1;i>=0;i--) { result=result+" "+stAr[i]; } return result.subString(1,result.length()); } |
Automation Test Engineer at Oracle was asked...
Code to find a missing number in an array 5 Answerspublic void missing() { ArrayList arr = new ArrayList(); int a[] = { 1, 3, 4, 5, 6, 7, 10 }; int j = a[0]; for (int i = 0; i < a.length; i++) { if (j == a[i]) { j++; continue; } else { arr.add(j); i--; j++; } } System.out.println("missing numbers are "); for (int r : arr) { System.out.println(" " + r); } } Does the numbes in an array lies in between a specific range ? Does the numbes in an array lies in between a specific range ? Show more responses Does the numbes in an array lies in between a specific range ? public static int findMissingNumber(int[] a) { int n=a.length; int expectedNumber=n*(n+1)/2; int actualsum=0; for(int i=0;i |