Adobe Interview | Set 4
Date Of Interview: 3rd December 2012
No. of Rounds: 1 Written exam + 4 rounds of PI
Type of Interview: Campus Interview for freshers
Written Round
The written round consisted of three sections 45 min each. The first was an objective type which consisted of 30 MCQs on basic Mathematical and Logical problems. Then there were 2 subjective papers each consisting of 10 questions. One was based on C programming and the other on basic engineering concepts.
Interview Round 1
Model a datastructure for a DFA that takes an event as parameter and performs a desired action.
Write a code that efficiently counts the total Set Bits in a number.
Write a code that efficiently calculates X power n where x and n are integers.
Write a code that efficiently calculates the nth term of Fibonacci series (He wanted a logn solution).
Interview Round 2
What is Synchronization? What is Mutex? Reader Writer Problem
There are 25 horses and a track which can race 5 horses at a time. Find the top 5 horses in minimum number of races. Assuming best horse always wins.
Write a function to check if a singly linked list is a palindrome.
Interview Round 3
What do you know about Volatile keyword explain with an example code.
Declare an array of function pointers that return a pointer to a func that in turn return a pointer to a char array.
Given a Roman notation of a number convert it into its decimal number. Write a function to do this.
Given a string, find the length of the longest substring with distinct characters.
What is Paging and why is it used?
Interview Round 4
HR Round: Normal HR questions
HIRED!! :D
Many Many congratulations to Saransh. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Interview Round 3
Declare an array of function pointers that return a pointer to a func that in turn return a pointer to a char array.
char * fun1();
char * fun2();
char * fun3();
char * (*f[3])();
int main()
{
f[0] =fun1;
f[1] =fun2;
f[3] = fun3;
return 0;
}
Interview Round 1
Model a datastructure for a DFA that takes an event as parameter and performs a desired action.
We can have a List of states, And each of these states in turn have a list(Dictionary in this case)
DFA = [[a , {'a' : a , 'b': b}] ,[b , {'b' :b , 'a':b}]] currentstate = 'a' event = 'ab' //code for transitionsAnswers For the Questions
InterView Round 1
2.)Write a code that efficiently counts the total Set Bits in a number.
//method 1 not the best though int countbits(int n) { int count = 0; if(n==0) { n = n&(n-1); count++; } return count; } //method 2 effeciency O(1) int countbits(int n) { n = (n & 0x55555555) + ((n>>1) & 0x55555555) ; n = (n & 0x33333333) + ((n>>2) & 0x33333333) ; n = (n & 0x0F0F0F0F) + ((n>>4) & 0x0F0F0F0F); n = (n & 0x00FF00FF) + ((n>>8) & 0x00FF00FF); n = (n & 0x0000FFFF) + ((n>>16) & 0x0000FFFF); return n; }3.)Write a code that efficiently calculates X power n where x and n are integers.
//method 1 not the best though int pow(int x,int n) { int p =0 ; if(n==0) return 1; p= pow(x,n/2); if(n%2==0) { return p*p; } else { return p*p*x; } }Interview Round 2
1.)What is Synchronization? What is Mutex? Reader Writer Problem
Ans:
What is Synchronization?
Mechanism where threads have serialized access to critical sections.
What is Mutex?
A special semaphore where the thread which acquires the semaphore lock has to release it before other threads can use that.
Reader Writer Problem
A resource is shared among various threads and more than one thread reads and writes into it simultaneously, which might lead into race conditions.
2.)There are 25 horses and a track which can race 5 horses at a time. Find the top 5 horses in minimum number of races. Assuming best horse always wins.
Ans :The minimum no of races to be held is 7.
Make group of 5 horses and run 5 races.Suppose five groups are a,b,c,d,e and next alphabet is its individual rank in tis group(of 5 horses).for eg. d3 means horse in group d and has rank 3rd in his group. [ 5 RACES DONE ]
a1 b1 c1 d1 e1
a2 b2 c2 d2 e2
a3 b3 c3 d3 e3
a4 b4 c4 d4 e4
a5 b5 c5 d5 e5
Now make a race of (a1,b1,c1,d1,e1).[RACE 6 DONE] suppose result is a1>b1>c1>d1>e1
which implies a1 must be FIRST.
b1 and c1 MAY BE(but not must be) 2nd and 3rd.
FOR II position,horse will be either b1 or a2
(we have to fine top 3 horse therefore we choose horses b1,b2,a2,a3,c1 do racing among them [RACE 7 DONE].the only possibilities are :
c1 may be third
b1 may be second or third
b2 may be third
a2 may be second or third
a3 may be third
The final result will give ANSWER. suppoose result is a2>a3>b1>c1>b2
then answer is a1,a2,a3,b1,c1.
HENCE ANSWER is 7 RACES
3.)Write a function to check if a singly linked list is a palindrome.
ans:
http://www.geeksforgeeks.org/function-to-check-if-a-singly-linked-list-is-palindrome/
For 5 top horses among 25 horses, min and max of 5 races are required, but among 5 top horses who is the best horse who win 1st positon: an another race is required, i.e total of 6 races.
Should it be top three horses??