Adobe Interview Question for Software Engineer / Developers






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

To be very frank I dont know the answer, but what I know is Java has Integer class which has a method bitcount which does the same thing in O(1).
This is the extract from the Java source code

i = i - ((i >>> 1) & 0x55555555);
1085 i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
1086 i = (i + (i >>> 4)) & 0x0f0f0f0f;
1087 i = i + (i >>> 8);
1088 i = i + (i >>> 16);
1089 return i & 0x3f;

Can someone please explain the logic?

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

This logic is coming from Hamming weight calculation.

- Anonymous March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sorry for incorrect C/P

i = i - ((i >>> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
i = (i + (i >>> 4)) & 0x0f0f0f0f;
i = i + (i >>> 8);
i = i + (i >>> 16);
return i & 0x3f;

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

integer is 2/4 bytes. therefore it takes a constant steps. Does it fits the definition of O(1) ?

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

According to above example it is 4 bytes.

- Psycho October 01, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use map for each byte.

- Rayden March 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

google MIT HAKMEM. But I wonder why adobe keeps asking these types of questions!It can never test the intelligence. If a person knows it he will tell it, or he wont able to tell it. If one can design this algo in half an hour he probably shouldnt be at adobe ;)

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

"Like" this comment

- airfang613 March 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

It shows how hard working and resourceful you are. Resourceful means proactively find answers for the problems.

- Anonymous March 18, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int BitCount(unsigned int u)
{
unsigned int uCount;

uCount = u
- ((u >> 1) & 033333333333)
- ((u >> 2) & 011111111111);
return
((uCount + (uCount >> 3))
& 030707070707) % 63;
}

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

I was asked the same question in Juniper. The Answer is "Look-up table"

- SH April 08, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int c;
Int N;
for(c=0;N;c++)
{
N&=N-1;
}
printf("No of set bit=%d\n",c);

- S May 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

The question is find it in O(1).

- Ravi November 16, 2011 | 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