What is an Algorithm?
AlgorithmsOne of the challenges associated with learning (and teaching) computer science is the additional vocabulary it introduces, either complex terms for simple enough ideas (algorithm, decomposition, abstraction), or terms that have specific meanings in other areas of learning (‘variable’ means something subtly different in maths, science and computer science). Whilst it is important that learners understand terminology, more important is their grasp of the concept or idea in question. An algorithm can simply be defined like this:
- An algorithm is a set of instructions that precisely describe an activity.
- The instructions should be such that any ‘actor’ could follow to produce the same output.
- An ‘actor’ refers to anything, whether human or computer, that is capable of computation.
- Must be sufficiently precise and unambigious: every step must be clear to the actor implementing the algorithm.
- Must be repeatable, producing predictable outcomes based on the same inputs.
- Can be represented in a range of forms, including natural language, pseudocode, flowcharts, or symbols.
Algorithms and programsThe term algorithm is often confused with program. Whilst the two are related, they have different meanings. An algorithm describes how to complete a specific task for any actor to carry out, whereas a program is the same algorithm implemented for a computer to carry out and written following the rules of a given programming language.
Want to keep
Raspberry Pi Foundation online course,
Programming 102: Think Like a Computer Scientist
turtlemodule in Python, or even by a floor robot.
One problem, multiple solutionsOne of the really interesting aspects of algorithms is that, for any given problem, there are numerous solutions. Whether they be simple, elegant, speedy, or inefficient, they are all valid, as long as they produce the desired outputs. In a group of learners, it’s entirely possible to get a different, but correct, algorithm created by each of them. At this point, it’s important to acknowledge their correctness, but also to encourage conversations and compare the merits of each approach. It’s this higher-order thinking that programmers need, in order to evaluate the ‘best’ approach whilst being aware of alternatives.
Why are algorithms so important?Depending on where they are used, the performance of your algorithm can have a significant impact on how useful it is. Different aspects of algorithm performance are important in different cases:
- The algorithm that produces the route a Sat-Nav system will follow can choose from many different routes from A to B. It’s important to the user experience that they get recommended the optimum route: the user will not be pleased with a route that takes an hour longer than necessary. However, the user is unlikely to care too much if their journey takes a minute longer, as long as they get to their destination.
- In contrast, the algorithms governing the behaviour of a self-driving car are taking split-second decisions based on the available sensor data. A bad decision by the algorithm could have life-and-death consequences, so these algorithms need to be robust and trustworthy.
- Every time you do a web search, the search engine uses an algorithm to rank the most relevant pages for that search. In this case the user cares about the accuracy of the search results, but also the speed of the search. The quality of the search experience may impact upon the popularity of that search engine and ultimately the money a company is able to make from it.
Problem solved?Algorithms are everywhere, as we’ve seen, but that doesn’t mean that they are fully understood. Far from it! Whilst there are many problems which have been solved using algorithms and plenty of ‘standard’ algorithms, there is still work to be done. As a society we’re finding new problems we can solve with algorithms in science, medicine, arts, politics, and AI. New algorithms are constantly being invented and existing ones improved. To keep doing that, the world needs more computer scientists.
Programming 102: Think Like a Computer Scientist
Our purpose is to transform access to education.
We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.
We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.