On Thursday, August 24, 2017 at 7:33:56 AM UTC-4, Bill wrote: > Pubkeybreaker wrote: > > A correct algorithm produces correct outputs for all inputs. > > To be fair, I would say that a "correct algorithm" is one that lives up > to its specifications. "Validating input" could be unnecessary and time > consuming, for instance.
Unnecessary? Then who validates the inputs? Someone has to. Whether it is done prior to invoking the algorithm, or during execution of the algorithm, it is still necessary.
If I design a function to compute a (real) > square root. It's not necessarily my job to indicate what happens if > the function is passed -3;
Yes, it is. This is part of correct software engineering.
> This is sort of the philosophy of the C programming language--that > people know what they are doing.
I'm sure that they do. Erroneous inputs still occur. Checking inputs also guards against incomplete specification of the algorithm.