Programming Fundamentals: Algorithms



Welcome to the final article in this series on programming fundamentals. Over the last several articles we have looked at many important concepts that are applicable to any programming language you will be using. These concepts included: variables, data structures, conditions, repetition, and functions. In this last article, we look at algorithms, something that requires the use of all the concepts previously discussed.

At the most basic level we can define an algorithm as a set of steps that when finished result in the completion of a task, or the solution to a problem. The first article in this series introduced an algorithm for making a cup of tea. Under this definition though we could easily deduce that entire programs are algorithms as they are made up of a series of steps, albeit many steps, for completing a task. However, when we discuss algorithms in the realm of computer science they are generally seen as small concise steps intended to complete a specific task.

Algorithms can be classified dependent upon how they go about solving a problem. Some examples of types of algorithms include: divide and conquer, greedy, and brute force algorithms. The classifications give details with regards to how the algorithm performs. A brute force algorithm is one that will try all workable solutions until a match is given. For example, if we wanted to find out a person’s pin number we would try to enter every 4-digit combination until we entered the correct one.

Over the years, a multitude of algorithms have been developed that have been applied to solve a wide range of problem from searching, and sorting data within a data structures, to rendering realistic graphics in games. In most cases, it is up to the developer to use an existing algorithm to solve a specific problem dependent upon the problem at hand. In some situations though, you may have to modify an existing algorithm to suit your need, or even design your own.

Algorithm design involves developing a series of steps that can be reused to solve a specific problem. There is a lot that goes into designing an algorithm. We must understand the problem we are trying to solve, ensure that our algorithm works for all the values we expect to be input, and that the algorithm is efficient. Efficiency generally refers to how much memory we need to use whilst our algorithm runs, and how long it takes for our algorithm to complete.

Algorithms are essential in computer science. They are designed to solve problems, but also to be reusable, so that they can be then applied by developers for whatever they need. A search algorithm could be used, for instance, to sort a range of numbers from highest to lowest in a leaderboard, We decide how to use them, and having so many algorithms already designed for us, we are not short of options.

So there we have it, a quick overview of algorithms. I purposely left this last article light on details as algorithms are such a broad topic which cannot easily be explained in this article alone. But at least you now have some understanding of what they are.

I hope this series has provided a brief introduction, so if you look elsewhere on your journey to becoming a programmer and run into the word algorithm, variable, data structure, or anything of the other things we have discussed then you will know exactly what is going on, and a little a bit about the why.

The last point to make is that this is unfortunately only the beginning. There are a lot of concepts I haven’t discussed, some big ones such as object orientated programming, recursion, nesting, scope, and many more things. But there are plenty of helpful people out there to guide you on your way. Good Luck, and have fun!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s