What is an algorithm?
Welcome to week two. We’re glad you’re still with us!
Last week, you spent time reviewing some essential programming skills, in particular, the use of functions. I shared how programmers use functions to build reusable chunks of code and manage complexity, and proposed an analogy with a machine as a useful tool to explain functions to beginners. This analogy was also useful when you looked at inputs and outputs of functions, or parameters and return values.
This week, you will explore what programmers mean by the term algorithm and how algorithms relate to the programs you write. There will be an opportunity to write some plain English algorithms, and then use your new-found list skills to turn these algorithms into programs. You’ll also extend your Python skills by learning to create and manipulate lists.
Once again, there are plenty of quizzes to help you check your learning, as well as opportunities to share and discuss with other learners on the course. I’d like to encourage you to take these opportunities in order to make the most of week two.
Algorithms
One of the challenges associated with learning (and teaching) computer science is the additional vocabulary it introduces; from complex terms for simple enough ideas (algorithm, decomposition, abstraction), to terms that have specific meanings in other areas of learning (‘variable’ means something subtly different in maths, science, and computer science). While 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.
Algorithms are used every day all around us to do all sorts of things, such as finding a route from A to B, searching the internet for the most-appropriate pages, or recommending movies based on your past viewing.
While you could substitute the word instructions for algorithms, there are some important characteristics of algorithms that make them distinct. An algorithm:
Must be sufficiently precise and unambiguous: 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.