# Interview Questions

interview questions shared by candidates

## Interview Questions

### Software Engineer at Arista Networks was asked...

Verify a BST 3 Answersremember and update max and min when you go down the tree Go breadth first and make sure left node < right node. That verifies the BST property at each level. Do an inorder traversal and see if the values are sorted, if they are it is a BST else not. |

### Software Engineer at Arista Networks was asked...

How do you find the next highest element in a binary search tree? 3 AnswersNext element in-order. - Get the node of the value - if the node has a right child, follow node to get the left-most child in that sub-tree - if no right child, the parent is the next highest element. I posted following code two weeks back, but someone removed it :( Let me post it again: typedef struct node_type { int info; struct node_type *parent; struct node_type *left; struct node_type *right; } node_type_t; node_type_t *_find_next(node_type_t *nodep, int *count) { static node_type_t *srcnd = NULL; static int scan_down = 1; if (nodep == NULL) { printf("find_next(node='%d'): got error\n", (srcnd != NULL ? srcnd->info : -1)); return NULL; } if (*count == 0) { srcnd = nodep; *count += 1; } if (nodep->info info) { if (nodep->parent != NULL) return(_find_next(nodep->parent, count)); else { printf("Can't find next node of '%d'\n", srcnd->info); return NULL; } } else if (nodep->info > srcnd->info) { if (!scan_down) return nodep; if (nodep->left != NULL) _find_next(nodep->left, count); else return nodep; } else { // nodep->info == srcnd->info if (nodep->right != NULL) { scan_down = 1; _find_next(nodep->right, count); } else { scan_down = 0; _find_next(nodep->parent, count); } } } node_type_t *find_next(node_type_t *nodep) { int count = 0; return (_find_next(nodep, &count)); } Interviewer said to me that recursive approach is not right solution, but above code is much better performance than his answer ;). The problem is that I couldn't answer the question within the interview time. I email above code to interviewer, on next day I got response that Arista doesn't have any position for me. :( |

### Human Resources Manager at GE was asked...

Tell me about your business. The financials, the key competitors, etc. 2 AnswersDo some research on your current employer, not just on GE mesin operator |

### Quality Engineer at NetApp was asked...

Using a normal justice scale (google for image), what's the minimum number of weighings required to find the heaviest of 9 different balls? 2 AnswersMinimum number of weighings is 2: 1.> Put 3 balls in each side of the scale and leave 3 balls on the table in front of you. If either side of the scale tilts to the heavier side then get rid of the other 6 balls and go to step 3. 2.> If both sides of the scale balance equally then you may eliminate that set of 6 balls and focus on the 3 left on the table. 3.> at this point you are down to 3 balls, either the set on the table or the ones that balanced heaviest in the first weighing. Repeat the procedure with the 3 balls. Place one ball each on either side of the scale and one on the table. Either the scale will balance leaving the heaviest ball on the table or the scale will not be balanced and you will have determined the heaviest ball there. That solution would work if all the balls weighed the same except for one. Maybe it was mis-worded, but the original question said 9 "different" balls. |

### Principal Engineer at Deem was asked...

The VCR Plus feature was described. In the TV programming guide each program/show/movie had its own code. When user wanted to program the VCR to record a particular show she just had to enter the program code from the guide - no need to enter the start and end time. I was asked to design this feature. How can it be achieved? 3 AnswersAssuming that TV shows start and end at the 1 min interval (ie won't need to set the start to 1:35:28), there are 1440 mins in 24 hours. One solution would be to have an 8 digit VCR Plus code: xxxxyyyy The first 4 digits will be the start time, second 4 digits will be the end time. This will take 8 bytes of space. That solutions assumes one channel. 1 digit for the day of the week. Assuming a max of 1000 channels, 3 digits for the channel number. 4 digits for the start time. Assuming the maximum show length is 1000 minutes, 3 digits for the record time. 11 digits. This could be optimized further if you restrict program start times to the nearest 5 or 15 minute interval, and record times to 5 or 15 minute intervals. Actually the VCR+ has 30 minute resolution. It packs the info into binary bits, then converts from binary to decimal, saving digits. The Java code is here: http://www.gginc.biz/java/vcr1.html |

### Support Engineer at A10 Networks was asked...

You have a building with 100 stories, and two identical balls. Your goal is to discover the topmost level from which the balls can be dropped without breaking. Do this in the least number of tries (drops). 4 AnswersDrop from 10th floor. If that works, drop from 20th floor. Etc. Until you reach a floor where the ball breaks. Say it's 70th floor. Then you know the highest floor is between 61 and 69, so you have at most 9 more drops. Worst case is floor 99 or 100, which you can find in 19 drops. This strategy will find the highest floor in any building of N floors in at most ((2*sqrt(N)) - 1) tries. Try to breakup the numbers into groups of 3 (B1floor, B2floor, remaining). Let answer be: 55 Try 1 (breakup into 30,30,40remain): B1-Floor 30, B2-Floor 60, B2 breaks, B1 doesn't So, answer < 60 Try 2: B1-Floor 20, B2-Floor 40, B1, B2 both survive So, 40 < answer < 60. Try 3(breaking into three 7's) : B1 - Floor 47, B2-Floor 54, B1,B2 both survive So answer is bigger than 54 but less than 60. 54 Shall we test it on the 1st floor? In my scenario I assumed don't have to. Drop it from 11,21,31,...,91th floor. The worst case is you make it towards to the 91th floor. If it breaks on 91th floor, roll back to test floor 82th to 90th (81th floor you've already tested.) The total worst case test number is 9+9=18 (only breaks at 90th or higher floor). If it didn't break on 91th floor, test 96th floor. If it doesn't break, always select the middle floor among the remaining floors. The worst case test number is 9+1+3=14. The reason why if ball didn't break on 91th floor and then you can go jump several floors is that you have two balls, which you can afford 1 loss from the ball. So you don't have to go one by one like from 82th to 90th. Show More Responses Delete floor 1 since you don't drop it at floor 1. Floors to drop is at floor 2~100 Section them in 3 parts A,B,C a=[2~34] , b=[35~67] , c=[68~100] 33 floors each. SET 1 - Drop it at floor 34, then 67. if breaks at 34, it leaves either [2~33] to test. 32 floors if breaks pass 34 and breaks 67 it leaves [35~66] to test . 32 floors if both pass, leaves 68~100 which is 33 floors, Assuming worst case scenario, assume it passed both. TOTAL DROPS : 2 WORST SET 33 floors. SET 2 - DIVIDE AGAIN to 3 parts D, E, F = [68~78], [79~89], [90~100] 11 each Same logic, test at 78, 89. if either breaks, leaves 10 floors remaining. [68~77] or [79~88]. if both passes, leaves 11 floors hence assume worst luck. [90~100] TOTAL DROPS 4 WORST SET 11 floors. Divide again to 3, but 11/3 = 3.6666666. Since we are testing heights, it makes sense to round up our first set. [90~93],[94~97], [98~100]. **if you get why, skip ** ** if we round down, we get 3 floors, 4 floors, 4 floors to cover all 11 floors [90~92],[93~96],[97~100] **If we do this, and test floors 92, 96 and assume worst case scenario, we are left with 97~100. 4 floors. ** if we did it rounding up, even in worst case scenario we get 3 floors. Assuming you skipped ** section, again our luck blows so we assume worst case scenario [98~100] remains. even if we got lucky, we'd be left with 3 floors, [90~92] or [94~96] TOTAL DROPS 6- 3 numbers remain. ROUND 4 >FINAL< so we have 3 numbers.. lets assume 98, 99, 100. drop it at 98 and 99 and 100. if it breaks at 98, top floor it can be dropped is 97 (7 drops) it it passes 98 and breaks at 99, top floor= 98. (8 drops) it passes both, then it can be either 99 or 100 so we test 100. if it breaks, its floor 99, if not its floor 100. (9 drops) So in the worst luck scenario, you only need 9 drops. |

### Systems Administrator II at Rackspace was asked...

What are the port number for smtp, ftp and http 2 Answers21, 23 and 80 smtp - 25 ftp - 21 http -80 |

Why do you want this job? 2 AnswersThere is no right or wrong answer here. It depends on who is interviewing you and what mood they are in that hour. ... but worse than other high tech companies. Not much of a market for BD anymore, so I guess you got desperate and applied at Oracle. Keep your options open. When Oracle lays you off, they will play hardball on your severance. Make sure you have a nest egg. |

### Services and Support at MuleSoft was asked...

How to you pick up (almost) real-time changes from database tables? 2 AnswersUse triggers that will call store procedures to record changes in a tracking table that's being polled at very high frequency. Triggers are poisonous for large distributed systems. |

### Engineering at Arista Networks was asked...

find the next in-order value in BST 2 Answers- Get the node of the value - if the node has a right child, follow that child tree and get the left most child node in that sub-tree - If no right child, then parent would be the next in-order value node - If no right child, then parent should be the next in-order value node if it's parent's left node. - If no right child, then parent should NOT be the next in-order value node if it's parent's right node. Here is the code: node_type_t *_find_next(node_type_t *nodep, int *count) { static node_type_t *srcnd = NULL; static int scan_down = 1; if (nodep == NULL) { printf("find_next(node='%d'): got error\n", (srcnd != NULL ? srcnd->info : -1)); return NULL; } if (*count == 0) { srcnd = nodep; *count += 1; } if (nodep->info info) { if (nodep->parent != NULL) return(_find_next(nodep->parent, count)); else { printf("Can't find next node of '%d'\n", srcnd->info); return NULL; } } else if (nodep->info > srcnd->info) { if (!scan_down) return nodep; if (nodep->left != NULL) _find_next(nodep->left, count); else return nodep; } else { // nodep->info == srcnd->info if (nodep->right != NULL) { scan_down = 1; _find_next(nodep->right, count); } else { scan_down = 0; _find_next(nodep->parent, count); } } } node_type_t *find_next(node_type_t *nodep) { int count = 0; return (_find_next(nodep, &count)); } As the matter of fact, Arista Network interview expected me to answer different way based on his algorithms which has much worse performance. I felt that interviewer didn't know the idea of recursive approach. |