Let's talk about what defines an algorithm. In general, it's a heap of steps which when followed, will produce an output (or multiple outputs) eventually. The eventually part is important because we don't want to make algorithms that go on forever without producing any outputs (having said that maybe we do for things like stress-testing or for testing another algorithm whose job it is to identify infinite algorithms and put a stop to them before they melt your cpu).
Input can literally mean elements or objects you put in the algorithm i.e. when functions take arguments, and/or it can simply mean the state that the system is in when the algorithm begins. Likewise with output; you can have an algorithm which will return one or more specific values and/or it will simply change the state of the system.
Alright so output's important, finiteness is important. An input(s) can be given but it's not always necessary i.e. the fact that you started the algorithm is all the input it needs like in the infamous 'hello world' algorithm.
Definiteness (i.e. precision and clarity) is also a big deal because you can't go telling a computer to perform a loop 'around about 5 times' (alright maybe you can via a random number generator but you're still being precise in defining the bounds of that number). Computers are brutally precise (that's what you get for having the first programmable computer made in Germany http://en.wikipedia.org/wiki/Konrad_Zuse ) so your programming needs to be precise as well as computers have no intrinsic arsenal of common sense, interpretation or disambiguation.
Alright so input, output, finiteness, definiteness. Last one's effectiveness which, like input, I consider more of a characteristic than a criterion. I'm sure there are plenty of ineffective algorithms out there like for example my microwavable pasta instructions say 'yeah buddy don't you worry, 12 minutes is ALL you need to heat this bad boy up' and meanwhile in 12 minutes time the pasta still isn't cooked. If only these instructions were made in Germany...
So that's about all there is to algorithms in terms of a rigorous definition: input, output, finiteness, definiteness and effectiveness.
No comments:
Post a Comment