Microsoft Interview Question for Software Engineer / Developers


Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

best case o(1) - by Eigen values AX = lamda X

avg - O(n) - go linearly from 1 to n

worst - fib(n-1) + fib(n-2)

- Anonymous December 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

best   -   lg(n)  ( matrix expo )

worst -   (n)

- NaMo December 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Best log(N)
Worts O(Fib(N))

- glebstepanov1992 December 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Best O(1) (if you can do infinite precision calculation of doubles by solving the recursive formula and finding the solution as a function of (n) and the eigen functions of the recursion)

Worst O(2^(O(1) n)) (exponential).

If you do a naive recursive approach, such as this:

int fib(n) {
	if (n == 0)
		return 1;
	if (n == 1) 
		return 1;
	return fib(n - 1) + fib(n - 2);
}

By increasing the recursion depth by 1, the value of "n" is reduced by a constant (1 or 2). Also each recursion leads to "2" other recursions, so in general, you are doing O(2^n).

- Ehsan December 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There are formula to calculate using formula so answer is O(1)

- Anonymous December 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Best Case: O(1) - hash every possible answer ahead of time
Average Case: I don't know
Worst Case: O(infinite) - have a while loop that doesn't do anything useful and never breaks

- Jonathan Nolife December 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

That depends on how the algorithm of fibonacci has been implemented, but assuming its implemented iteratively

best case - O(1) (asking for fib(0) or fib(1))
average case and worst case O(n)

If it has been recursively implemented without memoization

best case - O(1) (asking for fib(0) or fib(1))
average and worst case is O(2^n)

If it has been implemented recursively with memoization, it will be

best case - O(1)
average & worst case - O(n)

- confused_banda December 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Depends on the algorithm used. Fibonacci can be done in const time using a look up table.
Or in linear (O(n)) time using dynamic programming. Or in Exponential time (O(2^N)) using recursive calls.

- Rushabh October 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

Worst question.

- Anonymous December 24, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More