in reply to Re^5: Binary search algorithm.
in thread Binary search algorithm.
I misunderstood what you mean earlier. I hadn't noticed that $try was being modified in three places (rather than just at the top).
At no point is the value modified by ++$try or --$try used anywhere so you could just do:
That's not true. They're assigned to $lo and $hi respectively.
You probably meant to say that modifying $try here is superfluous. True, but irrelevant. Like you said, $try will get overwritten, so it doesn't matter if gets changed.
I would actually use +1 and -1, but keep in mind it's actually a teenie weenie bit faster to use pre-increment and pre-decrement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Binary search algorithm.
by jwkrahn (Abbot) on Aug 14, 2011 at 18:30 UTC | |
by BrowserUk (Patriarch) on Aug 14, 2011 at 18:44 UTC | |
by ikegami (Patriarch) on Aug 14, 2011 at 21:06 UTC |