What is an Algorithm

From Wikiversity

Jump to: navigation, search

Contents

[edit] What is an Algorithm

There are several definitions for the notion of an algorithm. As an introduction to the concept, we shall study some simple applications. Basically:

  • An algorithm is the step-by-step solution to a certain problem.

The problem need not be technical, or related to Computer. As an exercise, you can perform the following tasks below:

[edit] Tasks

  1. On a separate sheet of paper, list all the known possible steps in preparing/performing the following activities, be as descriptive and specific as you can be:
    • Cooking/Frying an egg, sunny-side up
    • The activities you do and the vehicles you ride on your way to school
    • Walking your dog at the park

These activities above might seem easy, but as you perform the tasks, you will encounter a series of trial-and-error sub-activities. For beginners, this is normal and you may tend to miss a few steps. Your solution to the case of egg frying should look like this:


1. Get the frying pan.
2. Get the oil. 
  a. Do you have oil?
    1) If yes, put it in the pan.
    2) If no, do you want to buy oil?
       a) If yes, the go out and buy.
       b) If no, you can terminate. 
3. Turn on the stove.
4. Etc... 



For the case of Frying an egg sunny side-up, have you forgotten to state that you will heat up the pan? Or maybe put in some oil? Should you put some oil in first before heating the pan, or should you heat the pan and then put some oil in first? These are the possible conditions that you may encounter in preparing the algorithms for this task.

Now, once you have mastered this process, you can convert a proposed algorithm into a pseudo code which can be more understandable for a computer.

  1. Again on a sheet of paper, list the following steps that you need to perform in evaluating the following equation:

(x4 + 25y2 + 2z) - 13

If you are a fluent mathematician, you can probably think of the steps in evaluating the quadratic equation above. In this case, you do not really have to prove or solve the equation yet that might be helpful if you aim to list the following steps that you need to do in solving this equation. As such, you need to consider which operation goes first and which will be dealt with last. As such, your final output should not only be the final answer/evaluation to this equation but also the series of steps that you should have produced - which ideally is your algorithm.

[edit] Conclusion

You can practise preparing algorithms by making your problems more complex, in a level-per-level basis. You can begin by adding cases involving numerous conditions, then you can make them more complicated by involving the use of flags, or counters and probably complex mathematical cases.

[edit] References

Complete Definition and History of Algorithms

Alan Turing