Algo0Notes

# Algo0Notes - In the first lecture we called computers...

This preview shows pages 1–9. Sign up to view the full content.

In the first lecture, we called computers malleable tools for processing data. We looked at data, we looked at how it is structured to be stored on the computer, let us now look how to describe the actual data processing. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Here are various definitions of the word algorithm. As you can see there is no strict agreement for a single definition. Highlighted in red are important features of algorithms. The number of instructions has to be finite, meaning that an algorithm cannot involve an infinite number of steps. It is also the case that the instructions have to be well defined. There can be no ambiguity. The algorithm has to prescribe precisely how data is to be processed. Algorithms are a set of step instructions for processing data. The instructions are sorted. The first instruction is executed first, the second one after that and so on. In computer science and certainly in our case, algorithms prescribe how computers are to process data. But remember, algorithms can only be executed by computers once they are encoded into programs. We will worry about programming later, for now we will worry about designing algorithms. For this, we need to find a way of specifying algorithms. 2
One option would be to use the English language. It is a powerful language, it certainly allows us to express all instructions we need, and it is familiar to us. 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
And in fact, the English language is used to specify algorithms, i.e. step by step instructions. Here is an algorithm for baking an apple pie. 4
The algorithm has an input, which in this case (i.e. for a recipe) are called ingredients. 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The algorithm also has an output. Here the output is represented with a photograph, easy to guess why. 6
And here are the step by step instructions. You see that there is a finite number of instructions, they are well defined, and they transform the ingredients in an apple pie. 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Note that some instructions require the repetition of an action. There is a loop in the set of instructions, to repeat some instructions. Bake at 425 degrees for 15 minutes, means repeat the baking from minute 0 to minute 15. We will see that for loops are a very popular way of specifying instruction repetition in algorithms. It is much easier to have a bake for 15 minutes loop as opposed to saying bake for 1 minute, bake for another minute, bake for another minute, …, bake for another minute. Another way of asking for an action to be repeated is to say that the action be
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 32

Algo0Notes - In the first lecture we called computers...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online