• Question: What are algorithms?

    Asked by Tilly on 1 Jan 2020. This question was also asked by hmulla18, reece437.
    • Photo: Gary Munnelly

      Gary Munnelly answered on 1 Jan 2020:


      Algorithms are basically just a set of steps which tell you how to carry out a task. Like if you were eating a cake, the basic steps would be, get the cake and while there is still cake left, take a bite, chew and swallow.

      You could say that an algorithm is a bit like following a recipe. You follow the steps and by the end you have created a cake (which you can, incidentally, eat using my previous algorithm).

      An algorithm in computer science is basically the same thing, except that we’re trying to tell the computer how to do a thing. The problem is that the computer is DUMB! Like, impossibly stupid. So we need to come up with incredibly precise ways to tell it how to carry out a task so that it doesn’t go off and do the wrong thing.

      As it happens, maths is extremely precise. So sometimes telling a computer how to carry out a task by describing it mathematically makes it easier for the computer to follow what it is supposed to do.

      What is amazing is that we have come up with algorithms which tell the computer how to learn. An actual set of steps which say “this is how to educate yourself”! How flipping amazing is that!?!

    • Photo: Giuseppe Cotugno

      Giuseppe Cotugno answered on 2 Jan 2020:


      Algorithms are a list of steps you need to make in order to achieve some result. You might require some initial information / object in order to carry out this list of steps.

      For example, if you wish to buy an apple from the grocery, you will picture in your mind all the things you need to do in the right order e.g. dress up, take your wallet with money, go to the grocer, select the apple, purchase the apple.

      Every step must take finite time (you shouldn’t take endless time to select the apple for instance) and within a algorithm you might need to take decisions or repeat some steps (e.g. if the grocer is closed then go to the next shop on the road until you find an open grocer).

      This is the basic version, then inside an algorithm there can be lots of other features (e.g. steps which have a probabilistic outcome etc.) but more or less it is the same thing.

    • Photo: Maja Popovic

      Maja Popovic answered on 6 Jan 2020:


      Algorithm is a sequence of steps necessary to transform some input into desired output.
      For example, to make a chocolate cream from eggs, sugar and chocolate:
      1) For each egg:
      1a) break egg
      1b) separate yolk from white
      2) add sugar to yolks
      3) mix it
      4) cook it for 10 minutes
      5) add chocolate into the hot cream
      6) mix it

      Usually, it is a sequence of instructions necessary for a computer to perform some calculation. The order of instructions is important, otherwise there might be problems (the computer cannot understand what it should do), or undesired outcomes (the computer understands the instructions but the result is not what you wanted — imagine adding chocolate after step 2 instead after step 4).

Comments