Pages

Wednesday, 11 July 2012

Adobe Interview Experience (Jan - 2008)

First Interview

1. 4 persons with different speeds attempt to cross a bridge in the night. There is only one torch and only two people can cross the bridge together and the joint speed is that of the slower of the two. Find the minimum time required to get everyone across.


Time taken by person 1 : 1 minute
Time taken by person 2 : 2 minutes
Time taken by person 3 : 5 minutes
Time taken by person 4 : 10 minutes

2. There are 2 cans - can 'A' contains a red liquid and can 'B' contains blue liquid. We take one unit of liquid from A and mix it with B. Then we take one unit from B and mix it with A. What's the proportion of red:blue in A and blue:red in B now? 

3. Write a non recursive function to reverse a linked list

4. There are a lot of events emanating from user input (mouse movement, keyboard key punches, mouse clicks etc). In the event processing code - there is a single giant switch case that handles these. How do we organize the switch statement to minimize the number of case checks. 


Second Interview 

1. Array A has size M+N and contains M integers in sorted order. Array B has size N and contains N integers in sorted order. How can we merge A and B without using a third array?

2. Find one pair of elements in a sorted array whose sum equals a given value. If the array is unsorted but contains only positive integers, how would you still solve it in O(n) ? 

3. Given 2 sorted arrays, how will you find the median of numbers contained in both of them in logarithmic time?

4. You have a program a.c that is compiled into a.exe and another b.c that is compiled into b.exe . b.exe appends a file 1.dat to a.exe and creates the file out.exe. Now assuming that out.exe is a valid executable, how would you write code in a.c so that data is read from the data file that is appended to the executable? 

5. What are the differences between new and malloc? You said you could overload new operator - what else must be done so that I can write my own memory management library? Do you know what name hiding is? Do you know what name mangling is - why is it required? 


Third Interview

1. Given n integers from the range 50...100 such that no integer repeats. The integers are stored on the disk - Now you're required to sort them in linear time. You are given only 7 bytes of storage apart from the few variables you will invariably need for writing the code. How will you sort if I gave you even less memory? (The code involved creating a bitmap using the 7 element array and setting the bit corresponding to the integers that was found and later printing out the map - I'd to write the code in all its glory and run it on a few cases) 

2. There are 3W and 2B hats in a basket. Persons labelled 1, 2, 3 are made to stand in a row such that 2 can see the hat 1 is wearing and 3 can see the color of the hats 1 and 2 are wearing. Now 3 remarks, "I've no idea about the color of my hat". Then 2 remarks, "I've no idea about the color of my hat either!". Then 1 correctly deduces the color of his hat - what reasoning did A use and what is the color of his hat? 


Fourth Interview

1. A pre order traversal of a complete binary tree is given in an array - then you need to print all the elements at a specified level.
2. You're given the following program:

-------------------------------- 
int main()
{
printf("TWO\n");
return 0;
}
---------------------------------

Add any code above or below the lines so that the output is 

ONE
TWO
THREE

Give me 10 different ways to do this and which of them are specific to C++? 

3. There's a gold bar 100 units in length. You need to pay a worker 2 units everyday for his work. What's the minimum number of cuts that you need to make and where will you make them?
4. What's the difference between an abstract class and a virtual class? ... from the standpoint of multiple inheritance? 
5.There are 50 famillies in a village each consisting of a husband and a wife. Each woman knows all the men who are thieves except her husband. Now the king announces that there is at least one thief in the village. What happens then?

7 comments:

  1. First Interview :
    Solution 1 :
    1 and 2 go to the other side
    1 comes back with the torch
    10 and 5 go to the other side
    2 comes back with the torch who was already there
    now 2 and 1 go

    2+1+10+2+2 = 17

    ReplyDelete
  2. First Interview :
    Solution 1 :
    1 and 2 go to the other side, 2 mins
    2 comes back with the torch, 4 mins
    10 and 5 go to the other side, 14 mins
    1 comes back with the torch who was already there, 15 mins
    now 2 and 1 go, 17 mins

    2+2+10+1+2 = 17

    ReplyDelete
  3. First Interview :
    Solution 3 :
    http://coding-interviewq.blogspot.in/2012/07/reverse-linked-list-iteratively.html

    ReplyDelete
  4. First Interview :
    Solution 4 :
    http://stackoverflow.com/questions/126409/ways-to-eliminate-switch-in-code

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  5. Second Interview :
    Solution 3 :

    1) Geeks for geeks : http://www.geeksforgeeks.org/archives/2105
    2) http://ocw.alfaisal.edu/NR/rdonlyres/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/30C68118-E436-4FE3-8C79-6BAFBB07D935/0/ps9sol.pdf

    ReplyDelete
  6. Third Interview :
    Solution 1 :
    1) http://designingefficientsoftware.wordpress.com/2011/03/31/bitmap-sort/
    2) http://letsalgorithm.blogspot.in/2012/02/bitmap-sort.html

    ReplyDelete