Newbie question about function return values

Brian Munroe bmunroe at tribador.nu
Fri Mar 14 12:51:29 EST 2003


>
> BTW - There are better methods of finding the next larger power of two.
> Try starting with the value 1 and doubling it until it is larger than
> the comparison value, for example.  It'll generally require less
> comparisons.  Also, you do not need recursion in this case, and should
> probably avoid it (you are not partioning the problem space very much
> with your recursion, and which is where recursion is most helpful.
> Instead, you are using it to perform iteration, which is a bad idea in
> almost all languages that provide loops).
>

Thanks for all who replied.  I figured out my mistake about the same time I was
getting responses.  Also thanks for the algorithm efficiency tip.  At the time,
recursion seemed like the quickest way to get it done, don't ask me why I
thought that way, but I've since back and re-written it as a loop.

-- brian






More information about the Python-list mailing list