bool ff()
{
while(true) {
int a = f() ? 2 : 0;
int b = f() ? 0 : -1;
if (a + b == 1) return true;
if (a + b == 0) return false;
}
}
On Wed, Mar 23, 2011 at 1:54 AM, Don <[email protected]> wrote:
> There is no upper bound on the runtime of this function.
>
> On Mar 20, 4:33 pm, Jammy <[email protected]> wrote:
> > clearly the prob. of getting true|false and false|true are equal to
> > 0.6*0.4. Therefore the following code works,
> >
> > bool uniform(){
> > bool f1;
> > bool f2;
> > do{
> > f1 = non_uniform();
> > f2 = non_uniform();
> > }while(!(f1 ^ f2));
> > return f1;
> >
> > }
> >
> > On Mar 17, 10:24 am, saurabh agrawal <[email protected]> wrote:
> >
> > > Given a function which returns true 60% time and false 40% time.
> >
> > > Using this function you have to write a function which returns true 50%
> of
> > > the time.
> >
> >
>
> --
> 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?hl=en.
>
>
--
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?hl=en.