|
面试时最经常被问到的问题(Frenquently asked interview questions)之Analytical, puzzles, and brain-teasers篇(5) where [] denote integral part of the log base 2 of n Example So if we want 0 to 15 dollars [log of 15 to base 2] + 1 = [3.90] + 1 = 3 + 1 = 4 boxes we need to have 4 boxes each having 1,2,4,8, dollars respectively.Now we know from binary numbers that any amount from 0 to 15 can be formed with this boxes. For 0 to 6 dollars [log of 7 to base 2] + 1 = [2.58] + 1 = 2 + 1 = 3 boxes we need to have 3 boxes each having 1,2,4, dollars respectively For 0 to 100 dollars [log of 100 to base 2] + 1 = [6.64] + 1 = 6 + 1 = 7 boxes we need to have 7 boxes each having 1,2,4,8,16,32,64 dollars respectively -Ameya Vaidya 7.What is the sum of the numbers from 1 to 1000? Depends what NUMBER means here: If means integer, that's 100*(100+1)/2=5050; If not, that's infinity. 8、You are an employer. You have ten employees. Each month, each one of your ten employees gives you ten bags of gold. Each bag of gold has ten pieces of gold in it. Each piece of gold weighs one pound. One of your employees is cheating you by only putting nine pieces of gold in each of his ten bags of gold. You have a scale (not a balance, a scale), and you can only take one measurement from the scale, only one (1) reading. How can you tell which of the ten employees is cheating you by using this scale and only taking one measurement? ---When your employees come to pay you at the end of the month, take one bag from employee number one's pile and set it aside. Take two bags from employee number two's pile and add it to the one from employee number one. Take three from employee three, four from employee four, etc... Once you have now compiled a pile of bags, you should have 55 bags (one from one, two from two, etc). Set the whole pile (all 55 bags) on the scale and take a reading. If all the bags were honest, you would have 550 pounds on the scale. If employee one is cheating you, then the reading would be 549, since you only have one bag from employee one. Likewise, if the measurement is 547, then 3 pounds are missing, and employee three is the thief. --- I think we are given a scale not a balance. So we can’t tell the exact weight of the bags. So how do we find out whether its 549, 547 etc.? --- Why does he need to weigh? Can't he just count? 9、How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started. --At the North Pole, The South Pole wouldn't quite work, since you can only go north from the South Pole. --Both answers (North Pole, and all points on the circle 1 mile north of the circle having circumference of 1 mile around the South Pole) are right. 10、How would go about finding out where to look for a book in a library? (You do not know how the books are organized beforehand) -- I would go and ask a person in charge of arranging the books instead of wasting my time in searching all of them -- This question is open ended , though Microsoft might be testing fundamentals on Binary search , Indexing etc by asking this. The approach I would take is , check out the index cards and find the shelf where the book is located. Then do an alphabetical search by physically going to that shelf. You can also say that you would start on the top of the shelf or the bottom depending on the "letter" name of the book etc. -- I would leave the library, drive to the exact location of the person who wrote this question, and slap them. 11、Imagine you are standing in front of a mirror, facing it. Raise your left hand. Raise your right hand. Look at your reflection. When you raise your left hand your reflection raises what appears to be his right hand. But when you tilt your head up, your reflection does too, and does not appear to tilt his/her head down. Why is it that the mirror appears to reverse left and right, but not up and down? -- It's mainly because man himself is "left-right" symetric but not "up-down" symetric. -- This is not a Physics issue... this is a matter of perception. When you stand in front of the mirror and raise YOUR LEFT HAND, the reflection is of YOUR LEFT HAND. By referring to "what appears to be his right hand" the question has essentially asked you to envision yourself rotated 180 degrees about a vertical axis, thus subtly introdUCing the apparent conflict between left and right. Why it works: Since humans are relatively symmetric along a vertical axis you are able to envision YOUR LEFT HAND as a suitable RIGHT HAND for your reflection. Humans are not generally symmetric along a horizontal axis (hey, I've never seen it, but that doesn't mean some freak isn't out there...), so it's much harder to envision feet as a suitable head and vice versa. 12、You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same? If you select 4 Jelly beans you are guaranteed that you will have 2 that are the same color. 13、You are given a scale which you are to use to measure eight balls. Seven of these balls have the same weight: the eight ball is heavier than the rest. What is the minimum number of weighs you could perform to find the heaviest of the eight balls?. Remember it's a scale not a balance. (i.e. It can just tell you if one side is heavier than the other it can't give you the exact weight). !..Umm. You can do this in 2 weighs. Put three balls on each side of the scale. That's a total of six balls you're weighing. If the three balls on each side weigh equally, you know that one of the two remaining balls is the heaviest. Weigh those two balls to determine which one is heaviest. If, however, one of the three ball combinations weighs most, remove all balls from the scale, then weigh just two of the three "heavier" balls. If those two balls are equal weight, the third, unweighed ball is the heaviest; otherwise the scale will indicate which of the two balls on the scale is the heavier one. So, what’s the difference between a balance and a scale? 14.How would you design a toaster? 1. Find out Voltage to be supported
|