Tuesday, 29 April 2014

Algorithms 1 - What are Algorithms

This is a quick series of revision notes, and links to the videos used in lessons about algorithms.  You identified them as the number 1 thing you wanted to revise, so here we go.

Why are they important

Algorithms are the shaping forces behind computing.

Going with the same logic as used in the video One of my favorite projects at the moment is the Google self driving car.  This makes sense especially when humans best reaction speed when they are concentrating is in the order of 2000ms.  My iphone has a processing speed of 1.5GHz, this means it can process 1,500,000,000 calculations every second.  Most desktop computers will do double this speed quite easily.

The implications of this are phenomenal.  The reason that this is possible is because driving a car can be described by algorithms.  Computers are great at algorithms - they can do them very quickly.

What do you need to know?

Referring to page 11, or section 2.1.7 of the syllabus. you need to know two things for GCSE.

(a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them
(b) produce algorithms in pseudocode or flow diagrams to solve problems.

Part a - is about understanding algorithms. algorithms have 3 basic parts. The sequence, a loop,. and a decision.

Sequence is important - look for algorithms that don't Make sense in terms of their order.  Can you put your trousers on before your boxer shorts?

There are two types of loops - for loops repeat an operation for every member of a list,or array.

While loops continue doing something until a condition is met.

Decisions are written using the if statement.


You should be able to read an algorithm and work out what it does.

For part B you should be able to find the algorithms for simple mathematical things such as:

  • Counting the members of a list
  • Summing the members of a list
  • Finding the mean of a list of numbers
  • Sorting a list of numbers
  • Finding the median of a list of numbers

Another Video - Just to recap.


Revision Questions

  • Write the following algorithms in pseudo-code:
  • Counting the members of a list
  • Summing the members of a list
  • Finding the mean of a list of numbers
  • Sorting a list of numbers
  • Finding the median of a list of numbers

Revision task 1

Write the pseudo-code for a game which selects a random number between 1 and 100, then prompts you to guess the number.  If you guess to high the program will respond 'too high', and if you respond too low, the computer will respond 'too low'

Revision task 2

Write the pseudo-code for a player of the above game to win in as few moves as possible.

No comments:

Post a Comment