NVIDIA Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

2N

This is how i calculated
(2^N-1)(2^N-1) + 2^N-1 = (2^2N - 1) - (2^N-1)

- Anonymous October 20, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 votes

which reduces to 2^2N - 2^N

- eugene.yarovoi October 20, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It'd be
log(2){((2^N) - 1)((2^N) - 1) + ((2^N) - 1)}
= log(2) {2^2N - 2^N}
Leaving away -2^N, since we are looking for the highest number of bits,
we get
= log(2) {2^2N}
= 2N

- chandan.jc November 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

another way of thinking:
for a * b, if b is a (N+1) bit unsigned integer, a * b means shift variable a N bits left, which results in a 2*N bit. And it's obvious that is reachable for a * b, since if a is the maximum digit for an N-bit integer, and b is 10...0(N zero following 1 one), then a * b is not the smallest 2*N-bit number

- minglotus6 August 11, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why do we do a log operation in the calculation?

- n15j October 14, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why do we do a log operation in the calculation?

- n15j October 14, 2015 | Flag
Comment hidden because of low score. Click to expand.
3
of 3 vote

Another easy way to understand this is : consider N to be 8 bits or 1 byte... An unsigned int of 1 byte can have a max value of 255. Now applying the given equation with the maximum values possible:

a*b + c = 255*255 + 255 = 65280

we know unsigned 8 bit value max is 255 . Similarly unsigned 16 bit value is 65536 and 65280 is less than 65536. Hence we need 16bits for storing the result or 2N bits.

- Abat January 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Don't forget to check your solutions with N = 1

- humbled April 25, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

also, what matters more is how you work throught the answer, not just come up with some fancy equation. Consider:
111*111 + 111 = 111 * (111 + 1)
The term in parentheses is at most N+1 bits and not greater than 2^(N+1) so it can shift by at most N bits. It turns into a simple shift by N bits, so the answer is 2N

- humbled April 25, 2013 | Flag
Comment hidden because of low score. Click to expand.
-2
of 2 vote

2N +1

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

2N-1

- Anonymous November 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

say n is 3
then 111*111+111
=111*1000
=111000
therefore the answer is 2N

- zhg January 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 votes

= 2^(2N) - 2*2^N + 1 + 2^N - 1
should reduce to
2^2N - 2^N
and not
2^(2N) - 2^(N+ 1).
You might want to recheck your solution now.

- The Coder October 21, 2012 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.


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