Re: Beginner Projects



Roedy Green wrote:
It is simpler code, so I don't count it as optimisation. Optimisation
that gets you in trouble is verbose, harder-to-maintain code. I
figure every student should be familiar with odd/even idiom.

Joshua Cranmer wrote:
Sometimes it can save you.

int mid = (low + high) / 2;
int mid = (low + high) >>> 1;

The first one breaks when low + high > 2^31-1, the second one doesn't (only when low + high > 2^32 - 1).

In other news, premature optimization only counts IMO when the change involves non-trivial optimizations.

You guys are absolutely right.

--
Lew
.