Skip main navigation

Introduction to algorithms

Find out what algorithms are and how they can be used to solve problems in programming.
It might come as a surprise to you, but we actually got quite a few algorithms in our game already. Let’s look at the setup beginning here. If you go through it step by step, we’ll see that this is actually an algorithm. We first say that let’s initalise the speeds of a ball, then place the ball, then place the paddle, set up the smiley ball– the positions, that is– and then set up the positions of all the sad bails. And after that, find the minimum distance that it should be between the small ball and one of the big balls. And that’s an algorithm.
We have a start, we have an ending, and we are doing things in between that are necessary for our programme to work. Each of these different methods do draw action on touch, action when phone is moved, update game. They are all algorithms. I have actually created a little document which you can find in TheGame folder where we have all the different versions. And this is called week5 updategameAlgorithm. And if you go through it, you should be able to relate this to the updated game and see that it is an algorithm. Try and go through it step by step and connect it with the code that you have in it.
There might be a little mistake in there, so see if you can spot that as well. But try and see how this is indeed algorithm.
This is how I normally work. I think about how is what I’m going to do an algorithm, how can I create small steps that will do what I need to do, and then I transform those small steps into a code.
In this video, we’ll look more in depth at algorithms and how they can be developed to complete tasks, and find solutions to problems.
You can also download the algorithm referred to in the video.
This article is from the free online

Begin Programming: Build Your First Mobile Game

Created by
FutureLearn - Learning For Life

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.

Learn more about how FutureLearn is transforming access to education