[algogeeks] Re: function problem

2009-09-18 Thread ashish gupta
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: function problem

2009-09-18 Thread v...@ibh@V singhal
yeah!!! arun is right
we can see same by probability!!
AB have 1/4 probability so AB will be in 3/4 probability..
CD is also in 3/4..
to call foo2 probabiliy will be by production rule3/4*3/4=9/8
ans=9/8*5000

On Thu, Sep 17, 2009 at 12:50 PM, Arun arunm...@gmail.com wrote:

 else condition wud be called 75% times. of that 75% times cD wud be true
 so foo2 wud be called (0.75)*(0.75)*5000 times.


 On Thu, Sep 17, 2009 at 3:02 AM, 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: function problem

2009-09-18 Thread Dave

Minor correction: 3/4 * 3/4 = 9/16, not 9/8.

110% probabilities occur only in politics.

Dave

On Sep 17, 3:08 pm, v...@ibh@V singhal vbhsing...@gmail.com wrote:
 yeah!!! arun is right
 we can see same by probability!!
 AB have 1/4 probability so AB will be in 3/4 probability..
 CD is also in 3/4..
 to call foo2 probabiliy will be by production rule3/4*3/4=9/8
 ans=9/8*5000



 On Thu, Sep 17, 2009 at 12:50 PM, Arun arunm...@gmail.com wrote:
  else condition wud be called 75% times. of that 75% times cD wud be true
  so foo2 wud be called (0.75)*(0.75)*5000 times.

  On Thu, Sep 17, 2009 at 3:02 AM, 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- Hide quoted text -

 - Show quoted text -
--~--~-~--~~~---~--~~
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

2009-09-17 Thread Arun
else condition wud be called 75% times. of that 75% times cD wud be true
so foo2 wud be called (0.75)*(0.75)*5000 times.

On Thu, Sep 17, 2009 at 3:02 AM, 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
-~--~~~~--~~--~--~---