Yahoo India Interview Procedure, Pattern and Model Question Paper by Raju

Few Questions: (45 min)
1. In a village in each family they give birth to children till they get a boy. IF girl child they try again. What is the ratio of boys to girls.
2. 2n+1 numbers in a list except for 1 num all had duplicates, how to find duplicate in O(n)
3. In 1000 wine bottles stack 10 are poisoned given 10 rats what is the minimum number of tries to find the poisoned one. Rat dies once it licks the poisoned wine.
4. Write 1,3,6,4 using +,-,*,/ to get 24 (no repeat of numbers)
5. Which is the DS used in dictionary mode in mobile (t9)
6. Which is DS used for chess program...to predict move each and every time..
7. There are $1070 dollars how to split them into bags such that asked for any denomination from $1 to $1070 , u must b able to give without opening bag...

Another paper:
1. First fit issues...
2. Algorithm to partition set of numbers into two s.t. diff bw their sum is min and they hav equal num of elements
3. Prog: given Numerator & Denominator.... print 0.3333333333 as .(3) 0.123123 as .(123)

Showing Answers 1 - 34 of 34 Answers

adity sharma

  • Mar 26th, 2006
 

gud evening ,i m doing electronics nd comm.engneering studying in 3rd yr.i want 2 do training so plz help me .

  Was this answer useful?  Yes

Sud

  • Apr 29th, 2006
 

Q1: Ans 1Expln: Let's say there are n couples.Assuming probability of having a boy or a girl is equal,The number of girls will be,Ng = n(1/2 + 1/2 + 1/2 .......)The number of boys will be,Nb = n(1/2 + 1/2 + 1/2 .......)Hence Ng/Nb = 1Alternate Expln:-Since probability of having boy or girl is equal, out of n couples, half of them will have their first child as a girl child and the other half would have their first child as a boy child. This is of course, assuming that the chances of having a boy child / girl child is mutually exlusive, exhaustive and equal. So, after the first birth, the ratio of boys to girls is 1.Now, those couples that already had a boy child stop, while those couples that had a girl child continue. As discussed above, there are n/2 couples who had a girl child and hence they continue. Out of these n/2, again, half the couples (i.e. n/4) might have another girl child and the other half (i.e. n/4) might have a boy child. Again, the ratio of boys to girls will be 1.By principle of mathematical induction (or let's say commonsense ;)) we can see that the ratio remains at 1 at all times!

AT.Ramya

  • May 24th, 2006
 

Question 2:

XOR all the 2n+1 numbers.. the result is the one unique number.. Its order is O(n)..

  Was this answer useful?  Yes

venugeethan

  • May 30th, 2006
 

Q6. for effective and better game play the alpha-beta pruning tree  or mini-max tree may be used.these are some DS recommended from Artificial intellegence pt of view.

  Was this answer useful?  Yes

Abhishek Tyagi

  • Jun 11th, 2006
 

well i dont thing the XORing the 2n+1 gonna done in O(n) becuz to XORing the numbers, they should be in a order so that the number XOR with that perticular number.. other wise there is high chance that u will get n 1's and one number whch need not be the correct number for arrengement u gotta need sorting and on avg case its O(nlogn) in case of Quick sort..Well according to me who i solved the problem is Using simple Binary Search Tree, wht chage u gotta do it is u have to modify the also as, the coming equal number should be put as the left child of the number, and put existing subtree of left on the left of the new coming repeated number ... its of O(n) on insrting nodes..then while to walk through the tree.. the number whch doesnt have left equal to it, is the unique number n here the complexity is O(logn)...Abhishek TyagiMCA National Institute of Technology Calicut,

  Was this answer useful?  Yes

Ravi Bala

  • Jun 26th, 2006
 

In the 2n+1 problem, i beleive you have not understood the trick of XOR :-(It works as follows: --> Take a set of numbers: 1,2,5,3,2,3,1. Here 5 is the odd number out and the remaining have duplicates. So do a simple XOR as 1^2^5^3^2^3^1(^ XOR operator). The answer is 5 and the time complexity is O(n). It's simple.(Try out using Windows Calculator, if you are reluctanct to write a code and check out.....)Cheers...

  Was this answer useful?  Yes

amrish

  • Jul 4th, 2006
 

Hi, I think the answer to Q.No. 1 is 1/2. To the ratio of boy/girl, we should find the expected No. of girl and boy in each family. Expected No. of boy in every family is 1, obviously to find the expected No. of girl in each family, we have to use formula E(x) = sigma (x * p(x)) where x is No. of girls and p(x) is probability of having x No. of girls. So, E(x) = [1*1/2] + [2*(1/2)^2] + [3*(1/2)^3] + ...... upto infinite. If you solve it, the answer is 2. So, the ratio is 1/2.
Regards,
Amrish.

  Was this answer useful?  Yes

Siddharth

  • Jul 31st, 2006
 

Well Amrish, i was just thinkin' abt ur solution.

Ofcourse, the number of boys = 1.

But, p(x) seems incorrect to me, since probability of havin' 1 girl only = 1/4 (1girl+1boy). 2 girls only = (2girls+1boy) = 1/8 ...

So it must start with 1/4.

--------------------------------------------

I can't find a soln to the problem. We can say that ratio = 1/(n-1) with a prob. of 1/(2^n). where (1<n<infinity).

  Was this answer useful?  Yes

gaurav khanduja

  • Aug 3rd, 2006
 

Ans 7: put in bag like 1,2,4,8,16,32,64,128,256,512 this sums up to 1023 and on the remaining split in bag as 1,2,4,8,16 and again for remaining 16 split in to 1,2,4,8 and then again 1 

  Was this answer useful?  Yes

Viswanathan

  • Sep 12th, 2006
 

The qn on T9 dictionary's data structure...I believe a red black tree could do it.This is because the searches will be lesser here and can also uniquely identify a word.

  Was this answer useful?  Yes

tapan

  • Sep 18th, 2006
 

yaa the answer is not that simple... ratio of boyes and girls will be between .25 and .5....

mathematically..

sum [1/(2^(n-1))][n/(1+n)]   n=1,2,3,.. infinity..

m i right.. the ratio cant never be 1...

  Was this answer useful?  Yes

Lior Yaffe

  • Nov 4th, 2006
 

Here is a program I wrote in Java for this exercise:public class Precision { public static void main(String[] argv) { new Precision().print(0.623123,2); new Precision().print(2.0/3.0,7); new Precision().print(0.997,2); new Precision().print(5.444444,8); new Precision().print(555.444444,2); } void print(Double d, int p) { Double x = 0.0; int round = d.intValue(); d -= round; d = d + 0.5 * Math.pow(10,-p); for (int i=0; i<=p; i++) { Double factor = Math.pow(10,-i); for (int j=0; j<10; j++) { if (d - factor < 0) { x = x + j*factor; break; } d = d - factor; } } x += round; System.out.println(x); }}If you run it you'll see that it works pretty well except for rounding problems with some double values. It even works for values bigger than 1.

  Was this answer useful?  Yes

Deepak S

  • Nov 14th, 2006
 

Answer to question 1 is: The ratio will be 1:1

the probablity of having a boy or having a girl is 1/2.

Lets assume that n villagers have the first baby ...
Number of boy = n/2 and numbers of girls = n/2

Now the n/2 who had girl have second baby ....
Number of boys in them = n/4
Total number of boys = n/2 + n/4 and number of girls = n/2 + n/4

Similarly after third baby
Number of boys will be n/2 + n/4 + n/8 and number of girls will be n/2 + n/4 + n/8
Ratio will be 1

there fore the ratio is 1

  Was this answer useful?  Yes

Pradipta Kumar Pattanayak

  • Nov 23rd, 2006
 

Hi

 I think ur answer is wrong. bcz inserting one elements in BST take O(n)

times and u r suppose to insert 2n+1 element . Just think about the complexity

that O(n^2).

XOR procedure is correct.

Another way to solve the problem in O(n):

We can sort the 2n+1 no using selaction sort . That will take O(n) time and then apply earching it will take O(n) . then total is O(n).

  Was this answer useful?  Yes

gundu

  • Jan 16th, 2007
 

que of coins:

ans:11

1,2,4,8,16,32,64,128,256,512,1070-1023=47:11 bags

  Was this answer useful?  Yes

peter

  • Apr 22nd, 2007
 

The mean of geometric distribution with p = 1/2 is 1/p = 2 and the mean of #boys is 1 (sum(1/2^i, i = 1, 2, ...)) and so the mean of #girls is 2 - 1 = 1.

  Was this answer useful?  Yes

Viswanath

  • May 18th, 2007
 

How come the answer is 11..?

I think the splitting must be this way..

Denomination Count Cost
1 1 1
2 2 4
5 1 5
10 2 20
20 2 40
50 0 0
100 1 100
200 2 400
500 1 500
    1070
1070
     

  Was this answer useful?  Yes

yatharth

  • Jun 25th, 2007
 

Can you plz explain how we can get 24 unless you take the mean of the two values i.e. 21 and 27 obtained

  Was this answer useful?  Yes

ashish

  • Aug 20th, 2007
 

Answer to the 1st question:
Let the no. of families be m
Let the no. of children in the families be n1, n2, n3......nm
Then the ratio of girls to boys is given by
((n1+n2+n3.....nm)-m)/m

  Was this answer useful?  Yes

andy

  • Apr 3rd, 2013
 

You just need 7.

1, 3, 9, 27, 81, 243, 729

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions