NVIDIA Interview Question for Software Engineer / Developers






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

{
char a;//the input variable
char b;// the output variable
int X=sizeof(a)*tot_siz;
b=a;
a>>=1;
while(a){
b|=a&1;
b<<=1;
a>>=1;
X--
}
b<<=X;
}

i think this should work..but then he asked me optimize the code further..i said you could use bit masking techniques in a look up format like 0x5555 and 0x3333 types...he then said there's a better way to get this done... am i missing something?

- SigPro July 13, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

bit_pos=0;
while(a && tot_size>bit_pos){
b|=a&(1<<bit_pos++);
}
would this alone wouldn't work??

- abhityagi85 January 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use a look up table. Store reversed bytes(obtained from a similar function as yours) in an array. Then reverse of number n would be array[n]

- Anonymous October 06, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

this would be good idea if total_size is really large

- Anonymous April 04, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

algo:-
(1)Anding the given no with 1,will give LSB.push it on stack.
(2)Right shift the no by 1.goto the step 1
(3)repeat step 1 and 2 until no become 0.
(4)when no become 0 pop bits from the stack.
write the code urself.........

- varsha jain January 16, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bitRev(char *p, int tot_size){

char *q;
int swapEle;

q = p+tot_size;

while(p<q){
swapEle = *p;
*p = *q;
*q = swapEle;
}
}

- S3 November 03, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You will have to increment and decrement p and q respectively

- iambob March 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Bug #2 in this code that it indends to swap (char) in the stream.
This would work to convert (LE to BE) or (BE to LE).

- dissoupo April 29, 2012 | Flag


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