The programming term I’ll talk about today will be “Algorithm”.
This one is long due since it's one of the most basic terms and at the same time one of the terms which even a lot of programmers will have difficulties to explain.
Let’s start with the formal definition.
A set of rules for solving a problem in a finite number of steps [1]
Okay, I guess that wasn’t very helpful.
Let’s break this apart and try to understand it better.
An algorithm always tries to solve a problem.
Which might be finding the fastest way to a location, calculating the greatest common divisor, calculating who is your best friend on facebook or finding the best way to fry a chicken.
Let’s take Fritz’s parents, they want to find out if they have enough money to spend the summer holidays on Hawaii.
Luckily both are mathematicians and they want to find out an algorithmic way out of this mess.
The problem is easily stated:
Can we afford to go to Hawaii?
Now we have to think about the input to this problem:
Input costs:
Flight cost per Person from Schwarzwald to Hawaii: F €
Hotel cost per Person at Hawaii all Inclusive: HA €
Hotel cost per Person normal: H €
Food cost: FO€
Trips and extras: T€
Which they will have to compare to:
Input savings:
Hans’s savings HS€
Karla’s savings KS€
Fritz’s savings FS€
Now, from the problem we’ll be very fast at the expected result of the algorithm.
Is the sum of all savings bigger or equal to the two possible cost models.
Now with the defined input and the expected result we have a clear roadmap to define our set o rules.
Do you remember that from the “formal definition” ?
Which we can easily create in finite steps.
Cost of all inclusive = F + HA + T
Cost without = F + H + FO + T
Total savings = HS + KS + FS
is total savings bigger or equal than any of the cost models?
And ready is our algorithm, we have a problem with a certain input, which leads us to a set of rules we have to follow to find our result.
This leaves us with the following definition of an algorithm.
But now, we really want to know if this all works out for our little family.
Let’s throw on our machine and we’ll see.
This means that Hans and Karla will enjoy their holidays on Hawaii without their kids.
Awesome, I have never fully understood what an algorithm was, but now have a somewhat better understanding.
Glad to have helped =D
I enjoyed reading, rich with information
this is good science programming @raycoms
Great post thank you for the insight. I'm looking forward to this event great!!!
Your explanation 'algorithms' are quite simple or easy to understand so,I really like your post raycoms.
It seems like there is a force which wants to make everyone believe that algorithms have to be very fancy and efficient to be called like that.
Or very complex/difficult to solve. I have never found myself calling something an "algorithm" when I was able to just type it out real quickly into a function and it works on the first run, even if it's still technically an algorithm.