Amazon Interview Question for Software Development Managers


Country: India




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

Answer is (4), Always.
I.e. IF f(n) = O(g(n)) ie. C*g(n) is an upper bound on f(n), where C is a constant,
2 f(n) = O(2g(n)) as 2g(n) WILL always be an upper bound on 2 f(n).

- Aniket March 19, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yes

since f(n) = O(g(n) ) means


f(n) <= C*g(n) where C > 0 constant


so 2*f(n) <= 2*C*g(n) will always true

- NaiveCoder March 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If O is function, then answer is (2), if O is constant, then answer is (4)

if f(n) = O(g(n)) = g(n)^2 Note: O(x) = x^2
then 2f(n) = 2O(g(n)) = 2g(n)^2

using this O function, if g(n) = 3, then f(n) = O(3) = 3^2 = 9
2f(n) = 18, O(2g(n)) = O(2x3) = O(6) = 6^2 = 36.
So, 2f(n) <= O(2g(n)).

But if O function = SQRT(x), then:
if g(n) = 3, then f(n) = O(3) = SQRT(3)
2f(n) = 2*SQRT(3), O(2g(n)) = SQRT(2x3) = SQRT(6)
in this case, 2f(n) > O(2xg(n))

So, I think answer is (2)

- Anonymous March 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Keep it up bro . See you in Amazon :P .

- paaji May 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

great prove

- very bad August 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i am lost, what is this? some mathematical theorem? O is neither function nor constant, it is in the order of

- Anonymous May 11, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

^ Doesn't know what asymptotic analysis is, please stop considering algorithms as your imaginational playground and learn some math.

- ananth March 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Always

- Anonymous March 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Always

- Chandu March 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote
Is 2f(n)=O(2g(n))? effectively implies is 2f(n)=O(g(n))? Because, in Big-Oh notation, we drop the leading constants. To answer "is 2f(n)=O(g(n))?", we have: {{{ f(n)=O(g(n)), which means f(n) <= Cg(n), for some C>0 & for all n >n0 Multiply by 2 on both the sides 2f(n) <= 2Cg(n) Now let D= 2C 2f(n) <=Dg(n), which implies 2f(n) = O(g(n)) Hence 4(Always) is the answer. Since 4(Always) is the answer, 1(Never) and 2(Sometimes) are NOT the answers. 3(Yes if f(n)≤g(n) for all sufficiently large n) is an implication of the assertion "f(n)=O(g(n))" provided in the question. Therefore, it is a part of the question and is not an answer - Murali Mohan August 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Is 2f(n)=O(2g(n))? effectively implies is 2f(n)=O(g(n))? Because, in Big-Oh notation, we drop the leading constants.

To answer "is 2f(n)=O(g(n))?", we have:

f(n)=O(g(n)), which means 
f(n) <= Cg(n), for some C>0 & for all n >n0 

Multiply by 2 on both the sides 
2f(n) <= 2Cg(n).  Now let D= 2C 
2f(n) <=Dg(n), which implies 
2f(n) = O(g(n)) 

Hence 4(Always) is the answer. Since 4(Always) is the answer, 1(Never) and 2(Sometimes) are NOT the answers. 3(Yes if f(n)≤g(n) for all sufficiently large n) is an implication of the assertion "f(n)=O(g(n))" provided in the question. Therefore, it is a part of the question and is not an answer.

- Murali Mohan August 18, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

ans is a..consider the case f(n)=g(n)

- Anonymous May 12, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hello.. I am too facing this question, but 4(always) is not only the answer,actually it's my quiz problem in coursera analysis and design of algorithm course, and its wrong for only option 4.. should we consider option 3 also?

- RV July 17, 2016 | 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