Andrew Stopford's Weblog

poobah

Sponsors

News

Articles

Family

Old Blogs

Student intern with Microsoft test questions

I was made aware of a few test questions that Microsoft ask as a first process to applicants on their student intern program. It's great to see these being asked and I figured I'd post up some pointers to help folks answer them as best as they can.

How do you test your code?

Answer should be "as much as possible" then explain how. If your a TDD fan then you can explain that and how you use it. If Waterfall, V-Model, RUP, CA and others are more your thing then explain how specification levels and testing meet. Either practice means testing and Microsoft will be interesting in hearing how you test. Don't lie however, your interviewer is likely to ask you about this question and if you know nothing about it then it will quickly show. Got tests on your project? Great explain a little about that, as a feeder for your interview.

Given a simple program designed to take inputs of integers from 1-1000 and to output the factorial value of that number, how would you test this program?  You do not have access to the code.  Please be as specific as possible

Note your not being to ask to code this question but consider first off what considerations you need to take before you answer the question. So given that the factorial number is any number that is 0 or above and the result of products of each number set you have 1 input and 1 output. So test fail conditions would be any negative numbers, 0 input value and a output value of 1, and incorrect results from a valid (0 or greater) input. Test pass conditions should test that a input of 0 equals a output value of 1 and that it take in every number bewteen 0 and 1000 and the expected result. You are testing every single range possible but the you run the risk of false postives raising from typos and other mistakes in such a big range of data. You could snapshot say 100 numbers that sample a different range and variance between 1 and 1000, this does mean that we can vary the number input range from each test to the next and prehaps expose errors.

Comments

Tony Webster said:

The factorial example is interesting. I wonder what exactly they are getting at with it.

First of all, it would be quite something if the program could calculate factorials up to 1000. I was trying to figure out how many digits 1000! has, and it is several thousand. It might just about be representable in an extended precision floating point quantity (runs up to 1.19e+4932 I think)

They might be looking for testing using the inductive condition - e.g. for a random sample for n:

   n! = n x (n - 1)!

Sample some values at n at random, and test that.

Also, I guess you could check the results against Stirling's approximation:

http://en.wikipedia.org/wiki/Stirling's_approximation

although unless you're recruiting someone with specifically mathematical background it's a bit of a big ask to expect them to have heard of this.

# January 19, 2007 1:21 PM

Michael Dorfman said:

I think there are some opportunities to be clever here.  Putting together a "row test" with 1000 input-output pairs looks attractive at first, but that depends on you having a guaranteed more reliable method of generating large factorials than the test under code, and faith in your ability to key extremely long numbers.

Personally, I'd make use of the fact that X! is divisible by all integers between 1 and X, and perform a series of divisions.

That being said, I wish I had thought of using Stirling's approximation.

# January 19, 2007 2:12 PM

Robert Chafer said:

Maybe the best thing to do is ask some questions back.  For example should the factorial calculator produce an exact answer or an approximation. Calculating an exact answer means validating the answer to 1000s of digits of accuracy. Also...we are supposed to be testing the factorial algorithm, not writing a new one.

# January 24, 2007 5:23 AM

venkatesh said:

i`m appearing for test for microsoft internship.can u give me more questions and details of it??

# February 8, 2008 12:11 PM

deepak kumar said:

can plss anyone send me d microsoft written test question pattern

# February 9, 2008 3:39 PM

Arun said:

can u please tell me the topics from which questions are asked in microsoft internships

# February 16, 2008 6:19 AM

ravi said:

we can test it by checking it for zero and -1 and 1

then chekc for any arbit number and for 1000 .. it should give values

then take any two consecutive numbers and find factorial of the two  n! = n * (n-1)!

then calculate the number of digit output it is giving

# February 16, 2008 11:19 AM

naroot said:

Well,

You can count 0's as well.

# January 16, 2010 7:56 AM

iswarya said:

can u plz mail me microsoft interns written test questions papers

# March 2, 2010 2:53 PM

mike said:

is the test long is there alot of questions?

# May 11, 2010 6:18 PM