Re: [algogeeks] MS written Reasoning question
Ans is 1 M.A + 2 B.Tech + 2 MBA + 1 MCA. Explanation: (1) Exactly one must be an MA. (2) Given: 2 b.tech are seleceted and the statement if at least one btech is selected then exactly 2 MBA are selected (vice versa condition) So exactly 2 MBA will be selected. (3) Remaining 1 would be MCA. So ans would be (d) option (b) is not correct as it says that only 2 mba and only 1 mca are selected but the total no of selected candidates are 6. -- Ashish On Fri, Apr 26, 2013 at 11:32 PM, rahul sharma rahul23111...@gmail.comwrote: 10 candidates appear for an interview and 6 selected. 2-M.A 2-MCA 4-BTECH 2-MBA. If at least one MBA is selected then exactly 2 btech are selected and vice versa. Of six candidates,exactly one must be an MA cndidate question:- which of the following statementsis definitely true:,if 2 btech are selected: a- two mca and 2 ma are selected. b- only 2 mbas and only one mca is selected c-one MBA and two MAs are selected. d- Two MBAs are selected. My approach:- we are with 2 btech,one ma,one mba remaining two can be 1 mba+1mca or 2 mcas But correct option is d. How is this definitely true and b is not?? plz comment -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[algogeeks] Re: probabiltiy + DP
i think there might be some modification On Thu, Sep 17, 2009 at 4:17 PM, Minjie Zha diego...@gmail.com wrote: Let PH(j,w) be the probability of getting w heads from 1...j coins, 0=j=k, 0=w=k. So we have: PH(0,0) = 1 PH( j, w ) = 0 if w 0 PH(0,w) = 0 for w0 PH(j,0) = (1-P(1))(1-P(2))...(1-P(j)) PH(j,w) = PH(j-1,w) + PH(j-1,w-1)PH(j) and equation should be PH(j, w) = PH(j-1,w) (1-P(j)) + PH( j-1, w-1) PH(j) pls correct if i am wrong... -- ashish Any comments? On Sep 9, 5:50 pm, Nagendra Kumar nagendra@gmail.com wrote: @all: There are k baised coins with probabilty of coming head is P(i) i = 1 to k. If all these coins are tossed together. find the probabilty of getting i heads ( i = k). think in Dynamic Programming. -Nagendra --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: function problem
actually it depends upon whether condition (AB) and condition (CD) can occur simultaneously or these conditions are mutually exclusive. If these two conditions can't occur simultaneously then foo2() will be called 5000 * 75/100 = 3750 but if they can occur simultaneously then call to foo2() will be less than 3750 depending upon the overlapping of the both conditions. -- Ashish Gupta On Thu, Sep 17, 2009 at 3:32 PM, ankur aggarwal ankur.mast@gmail.comwrote: 5. void foo1() { if(AB) Then {_/* */} else if(CD) then foo2() } How many time foo2() would get called given AB 25% of the times and CD 75% of the times and foo1() is called 5000 times --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: nth number of k bits
I think this should be easy to understand. #includeiostream using namespace std; // this function generated next big number of the list having k bit set. unsigned next_number( unsigned x) { unsigned smallest, ripple, one; smallest = x (-x); ripple = x + smallest ; one = ripple^x; one = (one2)/smallest; return ripple | one ; } // this function first set the initial to the first element of the list and then call next_number function //(n-1) times to get nth element of the list. unsigned int nth_number_of_k_setbit(unsigned int k, unsigned n) { unsigned initial = 1,i ; for (i = 0; i (k-1); i += 1) initial = (initial1) | (1); for (i = 0; i n-1; i += 1) initial = next_number( initial); return initial; } int main() { coutenter the value of kendl; unsigned k; cink; coutenter the value of nendl; unsigned n; cinn; cout.setf(ios::hex, ios::basefield); coutnth number of the increasing order of k-bit set list is:nth_number_of_k_setbit(k,n); coutendl; return 0; } hope this should help you. -- Ashish Gupta Ph. no. +91 9795 531 047 On Thu, Aug 27, 2009 at 10:35 PM, ankur aggarwal ankur.mast@gmail.comwrote: @shishir plz give an example.. its bit tough to understand for me atleast.. On Thu, Aug 27, 2009 at 6:10 PM, Shishir Mittal 1987.shis...@gmail.comwrote: Its a bit similar to finding the rank of the word COMPUTER in the dictionary among the words formed from C,O,M,P,U,T,E,R. Find maximum r such that (k+r)C(r) n. This represents the total number of numbers formed from 'r' 0 bits and 'k' 1 bits. Since n is greater, it implies it has an extra 1 bit in its representation. The problem reduces to finding [n - (m+r)C(r)] smallest number than can be formed with (k-1) 1 bits. here is a recursive function to obtain the result. int rec(int curr, int n, int k){ int r,j,comb,tmp; if(n==1) return curr+((1k) - 1); /* 1st number in the sequence with m bits. */ for(r =1,comb = 1; ; r++) { tmp = (comb*(k+r))/r; /* k+rCr = (k+r-1)C(r-1) x (k+r)/r*/ if(tmp == n) return curr + (1(k+r)) - (1r); /* All the 'k' left most bits should be 1 and rest 0 */ else if(tmp n) return rec(curr+(1(k+r-1)), n-comb,k-1); comb= tmp; } } Call rec(0,n,k) to get the nth number of the series with 'k' bits set. On Thu, Aug 27, 2009 at 12:28 PM, ankur aggarwal ankur.mast@gmail.com wrote: Nth number with K set bits We are given with k number of set bits (bit=1). We have to find the Nth number which has k set bits. for example k=3 the numbers with k set bits are as follows: 000111 = 7 001011 = 11 001101 = 13 001110 = 14 010011 = 19 010101 = 21 010110 = 22 011001 = 25 011010 = 26 011100 = 28 and so on we have to find the Nth number in this series... suggest some method -- Shishir Mittal Ph: +91 9936 180 121 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---