Engineering Interview Questions | Glassdoor.co.in

# Engineering Interview Questions

77,156

Engineering interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

17 Jun 2010
 How many rotations does earth make on its axis while going around the sun for one year.10 AnswersDepends on the Leap Year or non Leap Year 365 for Non Leap Year 366 for Leap YearThe question is flawed. It should either ask how many days earth takes in one revolution around sun, or how many days are in a year. The leap year is something imaginary humans have concocted to make the calendars look good. You can't say once is 4 years earth takes an extra day to go around the sun.It's to get you thinking about casting... the calender is a double casted to an int!Show more responses365.25 / yr I wouldn't say 365/ 366 leap year. Jain has a point.^It's either 364.25 or 366.25 depending on whether the earth spins in the same direction as it goes around the sun or not (I don't remember which it is and can't deduce it from the information that's available to me without looking it up). Imagine if the Earth did not spin at all on its axis so it would seem as if a year was equivalent to one day. It will take the Earth rotating either 264.24 or 366.25 times depending on the direction to seem like the 365.25 days that it does take.Every year it takes 365.25 rotations but while making calendar we ignore that 0.25 for 3 years and add an extra day in 4th year.365.25 is WRONG!!! Actually Anonymous is right! Just think about this (lay it out on your desk):
• How many days would there be if the earth would not revolve around its axis?
• How many days would there be if it turned once around it's axis?
• Now do again one, change the direction the earth revolves it's axis, but keep going the same direction around the sun ...
The concrete right answer is 366.25 Here you find details on the exact number (with other proof): :)All answers here are false and crap. To say a leap day is added to look good is a lie. To say 365.25 rotations is also a lie because it is 365.25 days not rotations. It takes 366.25 rotations making the 365.25 days, so that in 4 years 1461 days are made by 1465 rotations. If the Earth rotated the opposite direction then the 366.25 rotations would make 367.25 days and the 1465 rotations would make 1469 days. Simple math, but the idiots rule the world, while retarded ones worse than the idiots try to play smarter and CAN'T. Same as with Venus it takes 1.62509035863 orbits to make 0.62509035863 synod. Mathematical geometry that all cycles differ by exactly ONE. (Like the 366.2422 to produce 365.2422, and the 366.2425 to produce the 365.2425, and the 366.25 to produce the 365.25 and this is why Venus takes 1.62509035863 of 224.606267349 days to make 0.62509035863 of 583.924347116 so that if the math is not an exact balance then you have the wrong figures. 1+fractional A times one orbit = fractional A times one synod. And so 13 orbits around the sun appear from Earth as 5 times around the sun. Or more precisely when the math is checked to be exactly equal by this LAW that I discover, 13 orbits will appear as 5.00044481781 synods as seen from Earth, and 5 synods (superior conjunctions) will be 12.9988435764 orbits.This question makes no sense.It's other way around, only when earth complete one round, we call it a year. To make human calculations easy, we introduced leap yrs.

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

12 Jul 2013
 out of 25 horses select the fastest three in minimum number of races where in each race there would be exactly five horses.10 Answers6 races i thinkit could be 6 races... first five races taking 5 horses each,and then the 6th ace taking the 1st horse of each of the previous race,den select the fastest three among them.would be 5 races if a stop watch is given..... however solutions given before are wrong since the horse coming 2nd in the first race might be faster than the horses that come first in the subsequent race :) hence we have to assume that a timer is providedShow more responsesumesh no timer has been provided and it would be 7 races :)11 races First 5 races taking 5 horses in each race. Next 5 races taking in each race horses which have come first, horses which have come second, third, fourth and fifth....... Final 11th race out of 5 which have won in second set of races to find fastest 36 Race would be wrong answer. What if in one group all the 5 horses are fastest of all others. Then from first round of 5 races we might lose those 2nd and 3rd ones. My answer is also 11 Races.Round one - 5 Races -------------------- Including all 25 horses. 5 each race. Left with -> 15 horses [Take 1st,2nd & 3rd from each race. Which would be total of 5*3=15 horses.] Round two - 3 Races [ Grouping any 5 of 15 horses left] ------------------- Left with -> 9 horses [Take 1st,2nd & 3rd from each race. which would be total of 3*3=9 horses.] Round three - 1 Race. ---------------- Take any 5 horses of 9 horses left Left with -> 7 horses 3 (1st 2nd and 3rd) + 4 (remaining ones) = 7 horses Round four - 1 Race. ---------------- Take any 5 out of 7 Left with -> 5 Round Five - 1 Race ---------- Race of 5 horses left7 races: Split the 25 into 5 groups and make them race, this would be 5 races. Take the fastest horse of each group and make them race (6th race). Let's label the initial group of the top 3 horses of the 6th as a, b, c. The possible candidate for the 3 fastest are: a[1], a[2], a[3], b[1], b[2], c[1] We just need one last race to determine the top, the race would be between a[2], a[3], b[1], b[2], c[1]. The final result is a[1] then the top 2 of the 7th race.Easy: Correct answer is 11 but much easier method: 1. One race among 5 horses to find the fastest 3. 20 horses left not raced yet. 2. Now keep the 3 fastest horses you found and add two other horses out of 20 horses left to the race, again select the fastest 3. 3. Keep doing this for all 20 horses by selecting 2 of the horses left to race against the fastest 3 always. 1 race (to find the fastest 3) + 10 races (20/2 races to test all other 20 horses) = 11 racesConstant Time - 7 Races 5 Races among 5 each. 6th Race for all third place holders 7th Race for Winner of sixth race +two people who defeated him in 1st race + two people who defeated the second place winner in 6th race. Best Case - 6 Races (3 place winner of 1st race against other 20 and he wins all the time) Worst Case - 11 Races( Make the fastest 3 of each race run against the other 2 each time)

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

13 Oct 2012
 You are given a fixed number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps. Now given an amount for sending a parcel, you should design an algorithm to come out with the minimum number of stamps that should be used for attaining that amount. For example, if the parcel costed 30 rupees, it could be attained using one 20 rupee stamp and one 10 rupee stamp OR using three 10 rupee stamps OR using one 20 rupee stamp and two 5 rupee stamps OR using one 10 rupee stamp and four 5 rupee stamps OR using two 10 rupee stamps and two 5 rupee stamps. However, the minimum number of stamps is the case of one 20 rupee stamp and one 10 rupee stamp where only two stamps are used. The case where no solution is possible should also be handled, for example, a parcel amount of exactly 33 rupees cannot be attained.9 AnswersThe solution is attained using dynamic programming. The basic idea is that the minimum number of stamps used for attaining an amount x, is 1+minimum of (minimum number of stamps for attaining x-5, minimum number of stamps for attaining x-10, minimum number of stamps for attaining x-20,minimum number of stamps for attaining x-50). You can try to solve this first by assuming that an unlimited number of 5 rupee, 10 rupee, 20 rupee and 50 rupee stamps are available. And then you can take into account that only a fixed number of these stamps are available.And what is the time involved to get this done? I really liked the question.Simple to read but involves good amount of logic. I ve written down the algorithm but i believe i took more time than i initially thought i would take.I understand what the interviewer is trying to test and I know how to solve it, but what about more realistic scenario where parcel postage cost would be beyond given values like 3 units of currency or 37 units of currency.Show more responsesIn this specific case, dynamic programming is overkill. There's a better optimal substructure here: The stamp with greatest value less than parcel cost minus stamp values already committed minimize the total of stamps.1. find the stamp <= cost from highest stamp cost 2. num of found_stamp = found_stamp/cost, rem_stamp = found_stamp % cost 3. Do 1, then 2 until rem_stamp ==0 (done) or rem_stamp < least stamp available (not possible case)In the previous ans, after step 3 if rem_stamp !=0, go back to step 1, find next_stamp < cost (but smaller than value of found_stamp in previous iteration)i=0; boolean solPossible = false; do { if(cost % notes[i] == 0) solPossible = true; else i++; } while(!solPossible && (ivoid sendParsal(int cost) { int[] avlstm={50,20,10,5}; int i=0; while(cost>=5) { while(cost>=avlstm[i]) { System.out.println(avlstm[i]); cost=cost-avlstm[i]; } i++; } if(cost!=0) { System.out.println("Solution not possible."); } }void Foo(int cost) { if (cost % 5 != 0) Console.WriteLine("Not possible"); else if (cost stampCosts = new List() { 50, 20, 10, 5 }; int count = 0; while (cost > 0) foreach (int stampCost in stamptCosts) if (cost >= stampCpst) { cost -= stampCost; Console.WriteLine("Stamp: " + stampCost); count++; break; } } Console.WriteLine("Count: " + count); }

3 Dec 2012
 Can't disclose the exact question because of NDA, but here's some food for thought: 3 can be written as 1+1+1, 1+2, 2+1 4 can be written as 1+1+1+1, 1+1+2, 2+2, 1+2+1, 2+1+1, 3+1, 1+3 Given an integer, how many possible expressions exist? (1+2 and 2+1 are different)8 AnswersThere are total 2 ^(n-1)-1 expressions exist for any integer to be written on the basis of integers < the given Integer. Like for n=3, total 2^(3-1)-1= 3 expressions. For 4, 7 expressions exist and so on.Nof(1) = 0 f(2) = 1 f(n) = Σf(i) + (n-1), where i = 1 to n-1, n>2Show more responsesAder Lee: Shouldn't it be: f(n) = Σf(i) + (n-1), , where i = 1 to n-2, n>2 (i ranges from 1 to n-2, not n-1)f(1) = 0 and f(i) = i - 1 + sum_{i = 0}^{i - 1} f(i) Writing it down helps to find the sum: f(1) = 0(0) f(2) = 1 + 0(1) f(3) = 2 + 1 + 0(3) f(4) = 3 + 3 + 1 + 0(7) f(5) = 4 + 7 + 3 + 1 + 0(15) The first term(i - 1) equals the number of second terms and the second terms are the sum of 2 powers - 1 from 0 to (i - 2) so f(i) = 2^{i - 1} - 1Also there is a neat normal form to generate all variations. For the sake of simplicity I show it for i = 4: Start from 1 + 1 + 1 + 1 and for j in 1 to i - 1 add together j and (j + 1) and write down the numbers and mark the added number in the next iteration. | | | 2 + 1 + 1 1 + 2 + 1 1 + 1 + 2 From the marked numbers to (last - 1) run j and do the same as before. The first generates 2 more, the second 1 more and the last one none. gen by first | | 3 + 1 2 + 2 gen by second: | 1 + 3 We could also generate the one element sum(4) from the first one but it's not needed in the problem. Also this representation looks nicer in a tree form but I can only type text here.The marks moved to the begining of the rows since the forum probably has some nice mangling algorithm. I hope you can figure out how the normalisation works. Might post some python code which does this later.a coin change problem with little modification will do .

### Associate Test Engineer at UnitedHealth Group was asked...

28 Sep 2013
 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, puzzlesHi... 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 responsesThanks..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...

7 Nov 2013
 Given n numbers (P1,P2,P3,.....Pn). Divide them in m contiguous partitions such that the sum of the maximum is minimum. For e.g. (5,1,4,2,3) and m =2 then (5,1)(4,2,3)7 AnswersWas not able to solve this. But some guys used DP.Need to try all options according to m, Can be referred as spanning tree in depth of M. The leaf of the tree will hold the combination of the indexes that we've decided to divide by and than we can compute the min sum and choose the correct leafAssume they are all integers? Get the sum and divide by m. Then try to get sum that can get the exact same value. If can't increase m by 1, try again, until find.Show more responsesBinary search can be used to solve this.Let consider d[ i ][ j ] is solution of the problem when S = {s1, ..., si } and k = j. So it is easy to see that: d[ 0 ][ j ] = 0 for each j from 1 to k d[ i ][ 1 ] = sum(s1...si) for each i from 1 to n d[ i ][ j ] = minfor t = 1 to i (max ( d[i - t][j - 1], sum(si - t + 1...si)) for i = 1 to n and j = 2 to k Now let's see why this works: When there is no elements in the sequence it is clear that only one interval there can be (an empty one) and sum of its elements is 0. That's why d[ 0 ][ j ] = 0 for all j from 1 to k. When only one interval there can be, it is clear that solution is sum of all elements of the sequence. So d[ i ][ 1 ] = sum(s1...si). Now let's consider there are i elements in the sequence and number of intervals is j, we can assume that last interval is (si - t + 1...si) where t is positive integer not greater than i, so in that case solution is max ( d[i - t][j - 1], sum(si - t + 1...si), but as we want the solution be minimal we should chose t such to minimize it, so we will get minfor t = 1 to i (max ( d[i - t][j - 1], sum(si - t + 1...si)). Example: S = (5,4,1,12), k = 2 d[0][1] = 0, d[0][2] = 0 d[1][1] = 5, d[1][2] = 5 d[2][1] = 9, d[2][2] = 5 d[3][1] = 10, d[3][2] = 5 d[4][1] = 22, d[4][2] = 12 Code: #include #include #include using namespace std; int main () { int n; const int INF = 2 * 1000 * 1000 * 1000; cin >> n; vector s(n + 1); for(int i = 1; i > s[i]; vector first_sum(n + 1, 0); for(int i = 1; i > k; vector > d(n + 1); for(int i = 0; i <= n; ++i) d[i].resize(k + 1); //point 1 for(int j = 0; j <= k; ++j) d[0][j] = 0; //point 2 for(int i = 1; i <= n; ++i) d[i][1] = d[i - 1][1] + s[i]; //sum of integers from s[1] to s[i] //point 3 for(int i = 1; i <= n; ++i) for(int j = 2; j <= k; ++j) { d[i][j] = INF; for(int t = 1; t <= i; ++t) d[i][j] = min(d[i][j], max(d[i - t][j - 1], first_sum[i] - first_sum[i - t])); } cout << d[n][k] << endl; return 0;See Skiena's algorithm book. Dynamic programming chapter has this linear partition problem.Binary search the result and greedy check if it is obtainable.

### Electronics and Communication Engineer at HCL Infosystems was asked...

28 Jun 2011
 what is the HD?7 AnswersHigh deginationits HIGH DEFINATIONhigh definitionShow more responseshigh definationhigh definationhigh definition digital satellite tv channelsHard Drive, given the fact that the question is, "what is THE HD?" indicates that the interviewer is asking for an object.

19 Jul 2010