# A beginners Checklist for Algorithms

- Understanding your Task

Before one can have a checklist for algorithms, one needs to know what an algorithm is. Broadly applied, an algorithm is a procedure or function, the purpose of which is to accomplish a particular task. The goal can be present in a straightforward way with a ‘for each’ loop. The loop is a function set to achieve a specific job of iterating over each element of an array and accomplishing an assigned task for that element before moving on to the next segment.

Some quick vocabulary to know about algorithms. An algorithm that does not work or is not the correct one to choose — even though it may get the job done — is known as a heuristic.

When attempting to build an algorithm, the first task is to set the problem correctly. In short, BE CLEAR! Get the purpose and focus of the task at hand that this particular algorithm needs to accomplish. For example, if the problem is to find a more efficient way from A to B, make sure what “efficient” means is defined. It could be the minutes it takes or the number of steps. Just be sure to specify the task and what needs to be measured.

Secondly, what are the assumptions that you are going to use in this formula? What makes them credible assumptions? These two things are essential to laying out the algorithm’s task and the path to accomplishing it.

2. Tools to Use

When attempting to solve the question at hand, use a few tools. First, write it out in English, get your focus, and the steps clearly defined. Another powerful tool is pseudocode. Pseudocode can be indispensable when finding out how long this task will take when you get to the Big-O. It can be something as simple as:

some_function(an_array)

total = 0

for each i in an_array

total += i

Return total

There doesn’t need to be anything too complicated about it. If you are getting lost yourself, chances are the problem isn’t fully understood.

If you are ready, translate the pseudocode into a computing language in which you are proficient. One of the most helpful ways of thinking about going about an algorithm is to make it concrete. If you can draw it in a picture, you have a good idea of what is going on. It can also help you go about taking steps to solve the problem.

Just remember that algorithms are only equations that get the job done in the most efficient way possible. Sometimes there is no way around it except the long way. That is okay. Some datasets have to be taken through that way.

3. Simplify the Problem

Keep in mind that algorithmic datatypes may be recursive. What does recursive mean? Recursive means that the dataset, whatever it may be, can be broken down into a smaller version of itself. For example, a permutation, subset, tree, graph, point set, polygon, and string can be made smaller into a more simple to understand version of itself. An array that is w%(1..10000000) can also be thought-about [1, 2, 3, 4, 5]. It is only to make things more understandable for the formulation of the algorithm’s purpose. If it can do what it needs to do to an array of five items, then it can be applied to an array of one billion.

Understand your task, use your tools, and simplify the problem, and you will be well on your way to success.

Next up…”How to Poke Holes in Heuristics”