yeah!!! arun is right!!!! we can see same by probability!!!!!! A<B have 1/4 probability so A>B will be in 3/4 probability.. C<D is also in 3/4.. to call foo2 probabiliy will be by production rule>>>3/4*3/4=9/8 ans=9/8*5000
On Thu, Sep 17, 2009 at 12:50 PM, Arun <[email protected]> wrote: > else condition wud be called 75% times. of that 75% times c<D 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 > <[email protected]>wrote: > >> >> 5. void foo1() >> { >> if(A<B) >> Then {_/*.... */} >> else >> if(C<D) >> then foo2() >> } >> How many time foo2() would get called given >> A<B 25% of the times and C<D 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---
