Analytical Interview Questions | Glassdoor

# Analytical Interview Questions

2,636

interview questions shared by candidates

## Analytical Interview Questions

Sort: RelevancePopular Date

Jan 27, 2011
 You are standing beside a road watching cars pass by. The probability that you see a car pass by in 1 minute is 1/4. What is the probability that you see a car pass by in 30 seconds?8 Answers1-sqrt(3)/2why is thislet p=probability that you see a car in 30 seconds p(see car in first 30 seconds)=p p(see car in second 30 seconds)=p p(see car in the first 60 seconds)=2p-p^2=1/4 solving you get p=1-sqrt(3)/2 (reject 1+sqrt(3)/2 since it's over 1)Show More ResponsesI have a question on this solution: 1-(1-p)^2 is the probability of seeing at least one car, not the probability of seeing a car.You can also solve this using exponential distribution. From the question, you can deduce that the distribution has to be memoryless and hence there has to be a constant rate per unit time for the event to occur. Let the probability per unit time of a car passing by be p. Then from the given information 1/4 = 1 - e^{-p*T} The required answer is e^{-p*T/2} which gives the answer as reported above.Minor correction in above. The required answer is 1 - e^{-p*T/2}ans 1/2 as the person sees car in 15 sec of each 1 minute if we divide 1 minute into 4 parts (60/4 = 15 secs) s the probablity of seeing car now we are asked in 30 sec . the rate of moving of car will not change it will still continue to come at a rate of 1 in each 15 sec so the ans for each 30 sec would be 1/2 if we divide 30 into 2 parts . so in 15 sec one car is left .but for next 30 sec no car is going to come then itls probability would be 0 . now the ans is tricky which 30 secs are asked , the 30 sec in which car is seen or in which it is not seen by the man1 - sqrt(3)/2 is the wrong answer

Mar 21, 2010
 You have a genealogy: 1) Describe a data structure to represent it. 2) Given any two people within the genealogy, describe an algorithm to determine if they share a common ancestor. You just need to return true/false, not all ancestors.6 Answers1) Each person is represented by an object, with two pointers: "mom" and "dad" that point to their respective parent. 2) Choose one of the two people arbitrarily. Perform depth-first traversal and create a set of ancestors reachable from that person. Perform depth-first traversal on the 2nd person and for each node visited check if they are in the set; if yes, return true. Use a hash-set for best performance.calculate the height of person 1 in the tree, calculate the height of person 2. Move them up to be the same height. Then keep going until they intersect.@user: Its not a tree. A genealogy is a graph due to the fact that you have maternal and paternal trees intersecting. Therefore there is no root from which to calculate height.Show More ResponsesIf you've optimizing for worst case, hash set is O(n) for search. You'd do better in worst case with a sorted structure. You'd do even better if you store a "visited" flag at each node. Alternately you can number each node and keep an array of visited flags. since depth first seach might find a longer link through dad before checking mom, you're better off with breadth first search. Anything reachable in one hop would be seen before anything reachable at best in 2 hopsYes. Good points. The second traversal should be breadth first. The first traversal it doesn't matter, as you need to visit all ancestors anyways. The use of a visited flag is a good optimization. Based upon the way the question was worded, it wasn't clear if you could design the data structure to optimize the algorithm or not.I belive both the first and second should be BFS traversals

Mar 8, 2010

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

Mar 23, 2011
 Given a (potentially large) array of integers, all but one repeating an even number of times, how would you find the one repeating an odd number of times in an efficient way? eg [1 2 3 3 2 2 1 4 2] should return 47 AnswersUse any collection data structure to insert and remove the numbers, such that at the end the only one remaining will be the one repeated an odd number of times. For example we can use a tree. We consider on number at the time. We first search for the number in the tree. If found, we will remove it. Otherwise, we will insert it. At the end, the number (or the numbers, in general) repeated an odd number of times will be in the tree. For the complexity it is necessary to perform an amortized analysis. Another data structure that we can use is the hashmap. However, the space consumption and management could be high, if the map automatically resizes.Ex-or the numbers. For the odd occurrence, the ex-oring will not result in zero.Ex-oring is a great idea, one other solution is to sort the array and then in one pass you can find out the number that occurs odd number of time with quicksort avg case nlogn and worst case n^2Show More ResponsesFew steps of counting sort can help us do it in O(n) time. Step I: find min and max, thus the range Step 2: initialize array of the range with 0 Step3: as numbers come in, increment the a[number] by 1. Step4: scan the array to find the odd number.Ex-or is a good solution only if 0 is not in the input list. If 0 occurs odd number of times, not sure it will report it.Tellig about zero is an excellent catch.. +1by using LINQ it can be acheived. var numList = new List() {1 ,2, 3, 3, 2, 2, 1, 4, 2 }; var oneOccurance = numList.GroupBy(x => x).Where(y => y.Count() == 1).Select(y => y.Key); //Ans = {4}

### Senior Software Developer at Tower Research Capital LLC was asked...

Jun 7, 2010
 Another was a puzzle: A king orders 100 bottles of wine for a celebration. A courtier who's angry with the king over something puts poison in one of those bottles. The king has a way of identifying the poisoned bottle by giving a few drops of wine to a monkey. Since the poison is fast acting, the monkey will die immediately. Whats the minimum number of monkeys needed to find the poisoned bottle? 6 AnswersAssuming that there is only one poisoned bottle, then you only need one monkey- because as soon as it dies, you found the bottle. However, if there is more than one bottle, or suspicion of more than one bottle, you will need at least two monkeys.you need only one monkey since you will keep giving him wine till he dies and as soon as he's dead you know that was the bottle.I think it means we can only test once. So the minimum # of monkeys is 99, is it?Show More ResponsesThe answer is 7. Let monkeys be numbered 1-n. Each number less than or equal to 100 can be written as a 7 bit number. Hence, bottle one(0000001) is given to monkey 1. bottle three(0000101) is given to monkeys 1 and 3 and so on. Now say monkeys 1 3 5 died, it means that the number is 0010101 which means the bottle 41 is the poison!The way it's written, it seems like one would be the answer, or perhaps considering a monkey's tolerance for wine, N = 100 / (number of drops of wine a monkey can drink before passing out)... When asked with the condition that the monkey will die some time later, i.e. not immediately, the binary number technique described by Sri Krishna is best.make the courtier drink it

Feb 16, 2013

Jun 10, 2012

### Software Engineer at Pure Storage was asked...

Nov 11, 2010
 Given two base classes and a class derived from them how might one layout class instance memory so that polymorphism will work correctly. Problem was simplified in that one could assume memory was a series of same-sized slots and methods and attributes took up one slot each.3 AnswersI thought I did rather well, as I figured out (with some help) all but one aspect of the problem.hello , could you expand a little on the question and what you cam up with ?No, I can't really elaborate. It has been almost 3 years, the solution was convoluted, and I think I have blocked it out, since I don't remember much. I believe it involved having place holders for methods and attributes in the base class that carried over to the derived class. But I'd suggest a good compiler book, some time with the C++ compiler, and hours to kill if you really want to know the full answer.

### Office Manager at Oral Roberts University was asked...

Apr 25, 2014
 Can you fill in for a system manager.`3 AnswersYes, was my answer.Absolutely, i can fill in for a system manager.When I worked for ORU admissions, the office manager and the system manager both left and I took over for both of them.

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

Jan 20, 2010
 How to come out of a maze given that you can move one step at a time and you cannot turn left.3 AnswersRelies on the fact that if you keep your one hand on the left side then you would eventually come out of the maze.i cant understand what you mean. but here is what i think: when u want to turn left, make 3 right turns; means, instead of doing a 90deg antiClockwise, do a 270deg clockwise.start: if open to the right or blocked, then turn right go forward one if possible go to start unless done
2130 of 2,636 Interview Questions