Engineer Interview Questions | Glassdoor.co.in

# Engineer Interview Questions

80,620

Engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### Junior Software Engineer at Diaspark was asked...

26 Jun 2012
 4 _?_ 4 _?_ 4 = 20 Put the proper operators to get the output.5 Answers(4*4)+4 = 204*6+4-4-4Only 4's are there....no six... and you can't add more 4... its like 4 ___4___4 = 20 Now play with the operators....Show more responses4+4-4*4+4* +

### Software Engineer at ThoughtWorks was asked...

8 Jul 2012
 A box is divided into 4 boxes which is further subdivided into 4 boxes and so on. What is the best Data structure suitable for this scenario? 5 AnswersI gave an answer as tree bcos any tree can be converted to a Binary tree. But the interviewers where not satisfied with the solution.QuadtreeI think it should be Stack.There is recursion involved.Show more responsesthey might be looking for B Treetree is the correct answer. it is best suited for retriving also

### Software Development Engineer at Amazon was asked...

31 Jul 2012
 You have a list of sentences/words. How to find out the sub list that consists of a specific prefix? Ex: input: prefix="he", list = ["hello", "world", "hello world", "hey dude", "galaxy"....] output: ["hello", "hello world", "hey dude"]4 AnswersConstruct TRIE and search through it.APEW KHABAR SEMUA..For a pair of prefix and list of sentences, wouldn't it be just as efficient to just check the prefix against each sentence. If you are checking multiple prefixes constructing a trie would improve things.Show more responsesMostly the followup questions of any interview will be: imagie the dataset is big. Or whats the complexity & how will u improve it. So, its better to give the first answer as the best. :) Thats wat I did. Try creating indexes for your data to retrieve it faster. And as I already said, avoid naive approaches :)

### Systems Engineer at Tata Consultancy Services was asked...

1 Aug 2012
 Imagine that you are in a forest and because you wandered away from your group , you are now lost and stranded. You have no means of communication with the outside world and nobody to rely on. What would you do?5 AnswersI'd adaptTATA Network would never let you downI will try to get myself out of the forest through the road we entered into it. I will never get afraid of.Show more responsesi will get out of imagination...!11I will use the tricks of survivor Bear grylls tricks to survive and get myself out through the forest. Bear gryll quotes," You can't be a good horse rider untill you fall and awake no. of times".

31 Oct 2011

### 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[20]; 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[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

### Assistant Systems Engineer at Tata Consultancy Services was asked...

20 Oct 2012
 What will you do when your girl friend is getting married on the same day as a important client meeting?7 Answersi will do marriage first because meeting may be postpond or prepaid but marriage date not come again again.right manright manShow more responsesyes, firstly i will do marriageYesMarriage firstAs per time should Attend marriage first after that meet my client

### Software Development Engineer at Amazon was asked...

7 Apr 2012
 Given an integer array which consists of numbers from 1 to N with 1 number missing find the missing number. What will you do if 2 numbers are missing?4 AnswersGiven that the summation from 1 -> N = N(N+1)/2, we can use simple math to get a solution in O(n) time. We know that our array is "missing" a number, so it's length "L", is N-1. So we know that the summation for our array if it were not missing the value X could be calculated as N(N+1)/2, or (L+1)(L+2)/2. For a given array with length L, all we need to do is calculate what the expected summation is, iterate over the array and find the actual summation, then calculate the difference. public int findMissingValue(int[] sequence) { int length = sequence.length(); int expectedSum = ((length + 1) * (length + 2)) / 2; int actualSum = 0; for (int i = 0; i < length; i++) { actualSum += sequence[i]; } return expectedSum - actualSum; }You have an array of length N filled with numbers 1 through N+1 with one number missing. 1. bitwise xor all numbers 1 to N+1 2. bitwise xor all numbers in the array 3. bitwise xor the above two numbers to get the missing number, as duplicates will cancel out If two numbers are missing this approach and the sum approach fail. In this case I can't think of a faster way than sorting the list.For 2 number missing.. First split up the array into half from first half find the first missing number and second half find the second missing number. If 2 missing numbers are in first half then again divide the first half into 2 half and find it.Show more responsesUse a bitmap: keys are 1 to N and values are true/false. Iterate over the array and populate the bitmap. Iterate over the bitmap and the missing numbers are those that have the value == false.

### Executive Engineer - Civil Construction at National Thermal Power was asked...

28 Nov 2012
 What is the thing that you are most proud of in your life other than from your resume.6 Answersi m proud of my self confidencei m proud of my self confidencepositive thinkingShow more responsespositive thinkingPositive thinkingI am proud of my loyalty.

### Software Development Engineer at Amazon was asked...

21 Apr 2012
 Write code to count the number of bytes used for the int data type.4 Answersint CountIntBitsF() { int x = sizeof(int) / 8; return x; }^^ Your answer is incorrect. Look closely at the question.int *p; int count=(char *)(p+1) - (char *)(p);Show more responsesvoid count_bytes_used() { int a = 66000, bytes=0; while (a > 0) { bytes++; a = a >> 8; } printf("BYTES USED: %d\n", bytes); }
3140 of 80,620 Interview Questions