Questions in Adobe Tests n Interviews – Part 10

Interview Special:

Interview1:

He is very soft-spoken and one of my friend told me that this guy had brutally destroyed him. So I was terribly nervous. I usually am confident but in that room, I was stammering! Finally, it turned out that he wasn’t that brutal after all. Moral of the story: Stay confident at all times.

  1. He asked me my specialization? When I told him that I had none as I didn’t want to specialize in this stage, he was a little surprised but appeared satisfied with my reason.
  1. Why not further studies? (He had noted that I was third in my batch. He appeared impressed by that
    Answer : I told him that my profile clearly indicated that I’ve been trying to get into the industry via internships, industry-funded projects right from second year, second sem. I said that I was fully sure that I didn’t want to do MS anytime soon.
  1. He asked me to tell him about my favorite project.
    Answer : I told him about the web-browser that I had developed for cell-phones. I thought that was the only project which was closest to what Adobe was working on. He appeared satisfied with my answers.
  1. He then looked at my grades. He commented that my lowest grade – B- was in Digital Image Processing. I just looked at him like a doofus thinking of what to say. But he quickly added, ‘don’t worry, it happens.’ So people, be fully prepared to explain any anomalous grades. I was prepared with the explanation of the W in the my grade-sheet but not of the B- in DIP. I know that this is really stupid considering that I was interviewing with Adobe. Don’t make this mistake.
  1. He then asked me a question that had been asked in Round 4, written test:
    Describe an optimal algorithm to find the second minimum number in an array of numbers. What is the exact number of comparisons required in the worst case? Note that they didn’t ask the order in Big-Oh notation. They wanted the exact number of comparisons.
    Answer : I screwed up, big time in this question. I had superficially discussed this question with my friend a while ago and he had outlined an algorithm which I thought that I had understood, but I hadn’t. I started off explaining it but got stuck in the middle. He sternly told me to read it up again. One solution that I could tell him, and which I had written in the test was this:
    Use two variables – min and second min. Initialize them by comparing the first two elements of the array. This is (1) comparison. Then, go through the entire array, from index 2 to n-1 comparing each element, first with min and then with second min, updating each variable as necessary. This will involve a worst case of two comparisons for each element. Therefore, total number of comparisons = 2*(n-2) + 1 = 2*n – 3 comparisons.

    I’ll try to update this with a better solution, sometime soon.

  1. Given a polygon (could be regular, irregular, convex, concave), find out whether a particular point lies inside it or outside it.
    Answer : This is an easy, straight question from graphics. You shoot a ray parallel to the x-axis passing through this point. Start with odd parity. Change parity of ray each time it intersects an edge of the polygon (consider special case of when the line passes through a vertex of the polygon. Change parity only if it passes through a vertex which has one edge above it and one edge below the ray). If the parity of ray is even when it passes through the point, it is inside the polygon, else it is not.
  1. He asked me to explain Canny’s algorithm to him. (this was because my DIP project was related to this)
    Answer : This is simple. Study DIP
  1. Then, he gave me a practical problem to solve: Suppose you are given an image which contains some text and some photos. How do you find the location of the image?
    Answer : I gave various alternatives – from searching for RGB components, to using OCR.. he didn’t appear fully satisfied. I think he was looking for edge-detection, but that would fail, if the text contained tables, etc.

Interview2 :

He was friendly at the start but this interview was my worst. He asked me my favorite subject. I said that it was Programming. (He laughed at that)

  1. Which are the four storage classes in C. Answer : static, extern, register, auto
  1. Given a program:
int i; int main(){   int j;   int *k = (int *) malloc (sizeof(int)); ..//routine code }

Where are each of these variables stored?
Answer : I started off correctly, but he was able to confuse me. He brought in shared libraries, static libraries fundas into the discussion. We had a discussion for about twenty-minutes on this. Finally, he was happy with one of my answers because I had deduced which policy made sense and answered correctly. He said that out of all the people interviewed so far (I was second last), nobody had been able to answer all of these questions correctly.

  1. Question on polymorphisms.
    this is easy – get it from any C++ book. He tried to confuse me again, but this time I was ready and he was finally satisfied.
    Then he looked at my grades and said that out of all your grades, you have only two Bs and one of them is in Compilers. Why? (Damn it.. three non-A grades and that’s all they ask about. What’s wrong with this world?!)
    Didn’t you like Compilers? “Not in particular”, I replied. “Fine. Now, I HAVE to ask you questions on compilers”, he said.
  1. He again went back to the first question he had asked me. Once again, I had no satisfactory answer for him.
  1. Then he wrote out some code and asked me how the compiler will generate code for it. I gave some answer, but he was clearly not satisfied. I thought it was all over by then.
    Then, he asked me a DIP question. He commented that he had given that particular question to his juniors in IITB once and they had done a very good job at it. The problem is this:
    A teacher is writing on a blackboard and we want to pass all the information on the blackboard over a low-bandwidth network in real-time. How do we do it.
    Answer : I first suggested that we capture only a small portion of the board. To locate that portion, we could search for the chalk in the prof’s hand – of course, taking care that it had the blackboard in the background (no point capturing a video of the prof scratching his chin, na?). Further, if the prof was writing only text, we could convert the video into text by OCR and then transmitting. Simple diagrams could also be reduced to a set of vector-graphics instructions (we rarely, see the prof shading stuff). I think he liked my approach, but was not completely satisfied. Anyway, we left it at that and went forward.
  1. Given a set of words one after another, give me a data structure so that you’ll know whether a word has appeared already or not.
    Answer : I suggested various alternatives. but he kept helping me and finally, we came up with an array of pointers to 26-trees (each node of the tree has 26 children). Store every word as a path from the root to a leaf with pointers in the correct places. For example, hello would be stored as – pointer from ‘h’ index of the root array to a node which had a pointer from ‘e’ index of it’s array to a node which had a pointer from ‘l’ index of the array.. and so on. This is both time and space efficient.
  1. He asked me some questions on Interprocess Communication: What’s a semaphore? How are they used? He would often pick out words from my answers and ask me what they meant. He wanted to make sure that I really knew what I was talking about. I was able to answer all his questions, but I made the mistake of telling him, when we started off that I didn’t know much about this subject as I had done it a long time ago. He was very annoyed at that, apparently because a lot of people before me had said this.
  1. He then asked me some DB fundas. Transaction. Serializability, Consistent state, etc. I was able to answer all of them. I stumbled around a bit in a few questions where I was explaining correctly, but not using the keywords that he was looking for.
  1. Finally, he asked me whether I had any questions. I thought that I should say something to make him realize that I was not completely stupid and so asked him whether there was any logic to the order in which the short-listed candidates were called. This turned out to be a dumb move. The order was alphabetic and he sent me off with a parting shot, saying “You guys do pattern recognition and stuff and still you can’t recognize such a simple pattern” Me and my big mouth! Moral of the story: Don’t ask questions for the sake of asking.

Interview3 : Puzzle round

After the first two interviews, this one was like having a warm batch after being cold and wet for days! I did well in this one.

  1. There is a clock at the bottom of the hill and a clock at the top of the hill. The clock at the bottom of the hill works fine but the clock at the top doesn’t. How will you synchronize the two clocks. Obviously, you can’t carry either of the clocks up or down the hill! And you have a horse to help you transport yourself. And, the time required for going up the hill is not equal to the time required to go down the hill.
    Answer : You have to go up the hill and come back, with horse, without horse, getting four equations to solve four unknowns – time to go uphill – with horse, without horse, time to go downhill – with horse, without horse. Then you can go up the hill and set the clock to ‘(time when you left) + (time to go uphill with horse)’
  1. There was one more puzzle.. I don’t remember it. but I do remember that we started discussing ways of generating large prime numbers. I told him the funda of Mersenee primes (luckily remembered it) and he was decently impressed.
16.#include‹stdio.h› main(){ int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };
int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q);}

Answer:

SomeGarbageValue—1

Explanation:

p=&a[2][2][2] you declare only two 2D arrays, but you are trying to access the third 2D(which you are not declared) it will print garbage values. *q=***a starting address of a is assigned integer pointer. Now q is pointing to starting address of a. If you print *q, it will print first element of 3D array.

main( ){int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf("%u %u %u %d n",a,*a,**a,***a);printf("%u %u %u %d n",a+1,*a+1,**a+1,***a+1); }

Answer: 100, 100, 100, 2 114, 104, 102, 3

Explanation:

The given array is a 3-D one. It can also be viewed as a 1-D array.

2

4

7

8

3

4

2

2

2

3

3

4

100

102

104

106

108

110

112

114

116

118

120

122

thus, for the first printf statement a, *a, **a give address of first element . since the indirection ***a gives the value. Hence, the first line of the output.

for the second printf a+1 increases in the third dimension thus points to value at 114, *a+1 increments in second dimension thus points to 104, **a +1 increments the first dimension thus points to 102 and ***a+1 first gets the value at first location and then increments it by 1. Hence, the output.

main( ){int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) {printf("%d" ,*a); a++; }
p = a;for(j=0; j<5; j++) {printf("%d " ,*p); p++;   } }

Answer:Compiler error: lvalue required.

Explanation:

Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for the any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue.

main( ){static int  a[ ]   = {0,1,2,3,4};int  *p[ ] = {a,a+1,a+2,a+3,a+4};int  **ptr =  p;
ptr++;printf("n %d  %d  %d", ptr-p, *ptr-a, **ptr); *ptr++;printf("n %d  %d  %d", ptr-p, *ptr-a, **ptr);
*++ptr;printf("n %d  %d  %d", ptr-p, *ptr-a, **ptr);  ++*ptr; printf("n %d  %d  %d", ptr-p, *ptr-a, **ptr); }

Answer:111 222 333 344

Explanation:

Let us consider the array and the two pointers with some address

a

0

1

2

3

4

100

102

104

106

108

p

100

102

104

106

108

1000

1002

1004

1006

1008

ptr

1000

2000

After execution of the instruction ptr++ value in ptr becomes 1002, if scaling factor for integer is 2 bytes. Now ptr – p is value in ptr – starting location of array p, (1002 – 1000) / (scaling factor) = 1, *ptr – a = value at address pointed by ptr – starting value of array a, 1002 has a value 102 so the value is (102 – 100)/(scaling factor) = 1, **ptr is the value stored in the location pointed by the pointer of ptr = value pointed by value pointed by 1002 = value pointed by 102 = 1. Hence the output of the firs printf is 1, 1, 1.

After execution of *ptr++ increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the second printf are ptr – p = 2, *ptr – a = 2, **ptr = 2.

After execution of *++ptr increments value of the value in ptr by scaling factor, so it becomes1004. Hence, the outputs for the third printf are ptr – p = 3, *ptr – a = 3, **ptr = 3.

After execution of ++*ptr value in ptr remains the same, the value pointed by the value is incremented by the scaling factor. So the value in array p at location 1006 changes from 106 10 108,. Hence, the outputs for the fourth printf are ptr – p = 1006 – 1000 = 3, *ptr – a = 108 – 100 = 4, **ptr = 4.

main ( ){ static char *s[ ]  = {"black", "white", "yellow", "violet"}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
 p = ptr; **++p; printf("%s",*--*++p + 3);}

Answer:ck

Explanation:

In this problem we have an array of char pointers pointing to start of 4 strings. Then we have ptr which is a pointer to a pointer of type char and a variable p which is a pointer to a pointer to a pointer of type char. p hold the initial value of ptr, i.e. p = s+3. The next statement increment value in p by 1 , thus now value of p = s+2. In the printf statement the expression is evaluated *++p causes gets value s+1 then the pre decrement is executed and we get s+1-1 = s . the indirection operator now gets the value from the array of s and adds 3 to the starting address. The string is printed starting from this position. Thus, the output is ‘ck’.