You are on page 1of 8

Worksheet 4.1.

Examples of algorithms

Camilo Andres Quintero Rodriguez

Group 69

Teacher Javier Urrea

Caldas virtual – MisionTic


English
2021
WORKSHEETS
Example of an algorithm

Worksheet 4.1

Reading text
What makes a good algorithm?

Algorithm VS Recipe

An algorithm specifies a series of steps that perform a particular


computation. Algorithms are similar to recipes. Recipes tell you how to cook
food by completing a number of steps. For example, to make a cake the steps
are:
1. preheat the oven;
2. mix flour, sugar, and eggs;
3. pour into a baking pan;
4. etc.
But “algorithm” is a technical term and it is more specific than “recipe”.

Characteristics of an algorithm
If you call something “an algorithm”, it means that these characteristics are
all true:
1. An algorithm is an unambiguous description that makes clear what to
implement. In a computational algorithm, a step such as “Select a large
number” is not clear: what is “large”? 1 million, 1 billion, or 100?
2. An algorithm expects a defined set of inputs.
3. An algorithm produces a defined set of outputs.
4. An algorithm is guaranteed to terminate and produce a result. If an
algorithm could potentially be eternal and run forever, it wouldn’t be very
useful because you might never get a result.
5. The majority of algorithms are guaranteed to produce the correct
result.
An Example Algorithm find_max()
Problem: From a list of positive numbers, return the largest number on the
list.
Inputs: A list L of positive numbers. This list must contain at least one
number.
Outputs: A number n, which will be the largest number of the list.

Algorithm:
• Set max to 0.
• For each number x in the list L, compare it to max. If x is larger, set max
to x.
• max is now set to the largest number in the list.

An implementation in Python:
Does this meet the criteria for being an algorithm?
1. Is it unambiguous? Yes. Each step of the algorithm consists of primitive
operations, and translating each step into Python code is very easy.
2. Does it have defined inputs and outputs? Yes.
3. Is it guaranteed to terminate? Yes. The list L is not infinite, so after
looking at every element of the list the algorithm will stop.
4. Does it produce the correct result? Yes.

WORKSHEET 4.2
EVALUATION

1. The objective of an algorithm is to:


a. Perform a computation
b. Perform a recipe
2. … is more specific.
a. Recipe
b. Algorithm
3. The instruction “Select a large number” is:
a. Ambiguous
b. Unambiguous
4. An eternal algorithm is:
a. Useful
b. Useless
5. The objective of “find_max” is:
a. To find many numbers
b. To find the largest number
WORKSHEET 4.3
SELF –EVALUATION

Answer the following questions:

1. Entiendo cómo utilizar la estrategia de previsualizar y predecir con un texto.

Yes No Maybe

2. La estrategia de previsualizar y predecir me ayuda a tener una idea general de


qué se va a tratar el texto.

Yes No Maybe

3. La estrategia de previsualizar y predecir me ayuda a concentrarme más


mientras leo.

Yes No Maybe

4. Cuando previsualicé y predije el texto de esta clase, pude adivinar unos detalles
correctamente.

Yes No Maybe

You might also like