Engineer Intern Interview Questions | Glassdoor

# Engineer Intern Interview Questions

1,933

Engineer intern interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

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

Jan 10, 2012
 Print the BST in level order3 AnswersBasic idea: perform a breadth first traversal of the tree. Every time you dequeue a node, print it. This will give a level order print in linear time.Recursive function that starts at the root and recursively prints the value of each left and right node, along with the level order. bstprint(node, count) { if (node == null) { return; } print count + ": " + node.value; //pseudocode for printing cause lazy bstprint(node.left, count + 1); bstprint(node.right, count + 1); } bstprint(root, 0); //initial callif not tree: return nodes=collections.deque([tree]) currentCount, nextCount = 1, 0 while len(nodes)!=0: currentNode=nodes.popleft() currentCount-=1 print currentNode.val, if currentNode.left: nodes.append(currentNode.left) nextCount+=1 if currentNode.right: nodes.append(currentNode.right) nextCount+=1 if currentCount==0: #finished printing current level print '\n', currentCount, nextCount = nextCount, currentCount

### Software Development Engineer In Test Intern at Microsoft was asked...

Apr 21, 2012
 You have a building with 100 stories. You also have two glass balls. You can drop the glass balls as many times as you want before they break. How can you find the floor at which they start breaking with the fewest number of drops? 3 AnswersNot truly a brain teaser because the answer is mathematical.If you have N stories, you use the first glass ball to increment by sqrt(N) stories. Once that ball breaks, you use your second to go to the level of sqrt(N) below where it broke, and increment floor by floor. You know it must break somewhere in that group of sqrt(N) stories. I believe this method gets you a runtime of O(n^0.5).search for "two egg problem". its a minimization of maximum regret problem http://www.datagenetics.com/blog/july22012/index.html

### Hardware Engineer Intern at Microsoft was asked...

Dec 21, 2011
 If you increase the width of a PCB trace, does it decrease or increase the trace impedance?3 AnswersAs you increase trace width, impedance is lowered.The question is a little tricky (not really tho). The impedance of a straight line is described by Z=R+jX, where R is the resistance and X is the reactance. As the width of the trace is increased, R decreases. If we assume that there is no inductance, then the impedance will go down, as X=1/(jwC), and C=W*L*C0. However, in a very inductive space (like trace is curly and goes around itself a lot), then X = jwL, thus increasing the complex part of the impedance. I would go with the decreasing impedance, as on the PCBs resistance is the dominant term.If you increase the width of the pcb trace then it will help decreasing the resistance of the PCB trace. I give you a simple analogy if for example we consider the inductance as the negligible amount then, ( R=c (L/A)) where c is resistivity . And we are increasing the Area of cross section that is A. Then that is inversely proportional to the resistance and hence it decreases the impedance.

### Software Engineer Intern at Cisco Systems was asked...

Sep 10, 2013
 There are ten buckets of lead weights, with nine of them having equal weights of 10 grams each, while one of them has weights of 11 grams each. You want to find out which bucket has weights of 11 grams each, by using a scale, but you can only turn on the scale once.3 AnswersActually pretty easy outside of an interview. Order the buckets. Then take zero weights from the first bucket, one from the second, etc, and and add that to a pile. Then weight this entire pile once.@ Interview Candidate : how does that then solve the problemI think the problem goes like --> All buckets have 10 weights of 10 gms each and one has 10 weights of 11 grams each... If you number them 1 through 10 and take equal no. of weights out as the bucket number, The ideal sum should be : 1*10+2*10+3*10+....+10*10 = 550. But since one of them is 11 grams. So, lets say the 3rd bucket had 11 gm weights=> This means the total weight should be 553 ... Hope this helps

Mar 8, 2012
 Determine the 10 most frequent words given a terabyte of strings.3 Answersmapreduceexternal sort the 1TB data. replace each word as pair now use heap (top is the item with lowest count). when inserting a new pair, if heap.top().count < pair.count(), pop heap, push this pair. finally pop and print the heapMy solution will be out put the first 10Mb data, hash each word and put the strings which have the same hash code into the same file, then iterate through. Since same strings will always have the same hash code, even there is collision, it won't affect the result since we store the original string in the files. Then get each file's most frequent string, sort the result in decending order, then you will get the most 10 used words. This method can handle most of the big data interview questions.

### Software Engineer Intern at TechSmith was asked...

Oct 13, 2010
 Given a singly linked list, how can you find if there is a loop in the list?3 AnswersI came up with an O(N^2) method, but he told me there is a simpler O(N) method. (Look it up if you are interested)if you get back to the starting node after reversing the list, that means there is a loop in the list.http://ostermiller.org/find_loop_singly_linked_list.html

### Software Engineering Intern at Palantir Technologies was asked...

Jun 3, 2013
 You have a set of envelopes of different widths and heights. One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope. What is the maximum number of envelopes can you russian doll?3 AnswersSort the list of envelopes by x-coordinate. Then you already have the envelopes increasing by x-coordinate. Then, this is just a classic dynamic programming problem in disguise, the longest increasing sequence. Here, we want to find the sequence of envelopes that are increasing in y-coordinate, since after sorting we already have it increasing in x. Sorting takes O(n log n) and the algorithm itself runs in O(n^2), so total running time of O(n^2)Anonymous (Aug 16, 2013): Your algorithm is only valid if the width of each envelope equals to it's height, or is either greater or smaller than it's height. It would give incorrect result if there are envelopes with a different primary side. For example it will not work if there are the following envelopes in the set: 8x3, 10x5 and 4x9. The answer here should be all 3 envelopes, but will be 1 using your algorithm (4x9) since the height of the second envelope in the sorted list (8x3) is smaller than 9. Therefore initial sorting has to be by the primary side (as opposed to a specific side). Basically, an additional if-clause is required.use topological sort

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

Nov 5, 2013
 About the details, and interviewer will communicate with you when you are typing. 3 AnswersDivision - Divide A/B - repeatedly subtract B from A, until A < B. At which time print the number of subtractions as the quotient. The left over value in B, is the remainder.More efficient - http://www.prasannatech.net/2009/01/division-without-division-operator_24.htmlFor the sum case of digits try a binary search type approach: Let S be the sum we are searching for Sort the array - you can do this in n*Log(n) (see http://en.wikipedia.org/wiki/Sorting_algorithm) Here is where the binary search idea comes in Divide the sorted array into sub arrays A1 and A2. Take the mid elements of both sub arrays as pivots p1 and p2. This gives us 4 sub-sub arrays - In A1, we have the left of p1 as A11 to the right of p1 as A12. In A2, we have to the left of p2 as A21 and right of p2 as A22. If p1 + p2 > S then we look in A12 and A13, A11 and A13 and A11 and A12 If p1 + p2 < S look in A12 and A14

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

Jan 4, 2013
 Print a binary tree level by level in zigzag order3 AnswersYou should use two stacks: for the current level and for the next one.Use a queue. 1.Push root on queue. 2. Begin Loop Repeat while node is not equal to NULL: a. Pop b. Print value c. Push node's Right Child d. Push node's Left Child 3. EndThe answer given by me above is wrong because I was not clear about the zig zag ordering I applied it wrong !

Mar 7, 2014