# What is algorithm 5

## algorithm

A **algorithm** (also called solution procedure) is a guideline for solving a problem in a finite number of steps. This processing rule consists of a finite sequence of clearly executable instructions which always deliver the same results under the same conditions. The algorithm is described by a text consisting of elementary instructions.

### Definition and properties of an algorithm

With the help of the concept of the Turing machine^{} the following formal definition of the term can be formulated:

*A calculation rule for solving a problem is called an algorithm if and only if there is a Turing machine that is equivalent to this calculation rule and stops for every input that has a solution.*

The following properties of an algorithm can be derived from this definition:

- The procedure must be clearly describable in a finite text (finiteness).
- Each step of the procedure must actually be executable (executability).
- The method may only require a finite amount of storage space at any point in time (dynamic finiteness, space complexity).
- The procedure may only require a finite number of steps (termination).

In addition, the term algorithm is often restricted to the following properties in practical areas:

- The algorithm must deliver the same result under the same conditions (determinacy).
- The next rule to be applied in the procedure is clearly defined at each point in time (determinism).

abbreviated from: algorithm^{}

### Properties of algorithms

- Generality
- The algorithm solves a lot of the same problems, a whole class of problems.
- Repeatability
- With the same prerequisites, an algorithm always delivers the same result.
- Uniqueness
- The following step is clearly defined at each point.
- Finiteness / termination
- The algorithm consists of a finite number of steps and always comes to an end. The sequence of instructions must also be described in a finite text.
- Feasibility
- The instructions must also be clearly formulated and executable.

### Origin of the term

The term algorithm essentially comes from Abu Abdallah Muhammad ibn Musa al-Khwarizmi, who in 825 published the book "Al-kitab al-muchtasar fi hisab al-dschabr wa-l-muqabala". This book is about rules for restoration and reduction. The book had a major impact on Arabic and European mathematics. It was also translated into Latin, and the word algebra developed from the title al-dschabr. This book also begins with the words "Dixit Algorithmi ...", which means something like "Also Spoke Algorithmi". This is a word creation derived from the name of his birthplace al-Khwarizmi.

### Structogram

Algorithms are represented in structure diagrams.

### Basic structures

#### Statement block (sequence)

= A sequence of instructions

#### Loops (repetitions)

= As long as a condition is met, the action is repeated.

##### Head controlled loop

= As long as a condition is met, an action is carried out.

##### Foot operated loop

= An action is carried out until a condition is met.

#### conditional statement (branch)

= If a condition is met (yes), action 1 is carried out. If the condition is not met (no), action 2 is carried out

### Examples of algorithms

### mathematics

- Division algorithm
- Euclidean algorithm
- Sieve of Eratosthenes for determining prime numbers

### Computer science

### Everyday algorithms

In our everyday life there are often situations in which we use algorithms. For example, when making coffee or starting up the computer. The coffee making and the computer start-up are algorithms, since these processes are always carried out in the same way.

Further examples are:

- Cooking recipes
- Playing a tune
- Repair and operating instructions
- Help for filling out forms

### Coffee making algorithm

- Fill the jug with water
- Put the jug in the coffee machine
- Place the filter in the coffee machine
- Pour coffee powder into the filter
- Switch on the coffee machine
- Get the cup from the cupboard
- When the coffee has run through, pour it into a cup

### Computer startup algorithm

- Press the start button on the computer
- Turn on the screen
- Let the computer start up
- Choose an account
- Enter password (login)

### Algorithm for writing and sending a letter

- Write text on sheet
- Put the sheet in the envelope
- Seal the envelope
- If the address of the recipient is known, then write the address on the envelope, otherwise look for the address in the address book and write the address on the envelope
- Go to a post office
- If the letter weight is <20 grams, buy a 55-cent stamp, otherwise buy a 90-cent stamp
- Stick on the stamp
- Send letter

### Algorithm for brushing teeth

When brushing your teeth, the problem can arise that the toothpaste tube is empty and you have to change it. When the tube is full, you can continue to use it, but when you empty the pasta you either have to take a new one out of the cupboard or, if there isn't one, go to the store and buy one.

### Algorithm for determining minerals

Problem: You have two minerals (emerald and ruby) that have to be determined.

### Window opening algorithm

- when you sit, get up
- go to the window
- turn the lever up to tilt it
- to open, bring the lever into a horizontal position

### drive

**Algorithm for starting the engine and driving off a car with an automatic transmission**

- Operate the ignition
- Turn on the lights
- Release the handbrake or parking brake
- Shift gear to "Drive" or "Drive"
- Depress the accelerator

### "Mc Drive"

- Drive up to the exit hatch
- Place an order
- Pay
- Take order
- Drive away

### Special algorithms and algorithm classes

### Genetic Algorithms

### Algorithm of the Week for the Computer Science Year

Binary search Sorting by inserting Fast sorting algorithms Spelling numbers correctly Labyrinth and depth-first search Robots in the labyrinth Shortest paths Topological sorting Euler circles Page-rank algorithm Broadcasting (spreading rumors) Parallel sorting Error-detecting codes### Teaching idea

- Have an algorithm developed and run through. Are the criteria for an algorithm met?
- Have one student write an algorithm for another student. If necessary, you can initially hide the target description and then discuss whether the algorithm has done what it should.

A teaching unit on algorithms can also be started through a teaching text. Here is an example of a teaching text that also contains tasks for different skill levels: Teaching text on algorithms

### Web links

- Which country is the origin of the falafel
- What was the budget for Black Mirror
- A UI developer gets paid well
- What is the placement of BBDNITM
- Are the Welsh tougher than the English
- What percentage of people snore
- What is the lotic ecosystem
- Which industries use a lot of electricity?
- Wayanad is good for a relaxing excursion
- How is the book War and Peace

- Baggy jeans are making a comeback
- Who Built Country Life (Social Game)
- Who cracked the Enigma code
- Cannabis seeds can be consumed by the elderly
- What do politically liberal people believe in?
- Which sector is advertising
- How can I pretend to be a CEO?
- What is your rating of Dhaka Bangladesh
- Is PSG College co ed
- Bitcoin was seen as a failure
- What is the Best JPEG Compression Software
- How does reverse DNS lookup work
- Who are you 4
- Advocate euthanasia
- What is the shortest question ever
- What if Operation Northwoods happened?
- Why is it difficult to start a business?
- Which state has 1,350 miles of coastline
- Category theory What is a morphism
- Why is product simplification necessary
- What makes startup culture so attractive?
- What is 000 exe
- Should I visit Moscow or St. Petersburg?
- What is mental power