Algorithms

Communication 1

As of yesterday, only 20 people have subscribed to the mailing list

Please subscribe to the mailing list as soon as possible

How: send me an e-mail (silvio.peroni@unibo.it) using your UniBo email address, and I'll add you directly to the list

Then, you can receive / send emails from / to compthink1819@googlegroups.com

Communication 2

We have a new Telegram group for instant-messaging!

Telegram is a cloud-based mobile and desktop messaging app with a focus on security and speed, it is an open source software, and can be used in any device (it has been developed for mobile and desktop devices)

The invitation link to the group will be sent on the mailing list – thus, please, subscribe to the mailing list first

Communication 3

Exam sessions dates (informal):

  • 25 January 2019

  • 15 March 2019

  • 22 May 2019

  • 21 June 2019

  • 17 July 2019

  • 20 September 2019

For each date:

  • written examination: 10-12

  • project oral colloquium: 13-16

Any question about the previous lecture?

Historic hero: Ada Lovelace

English mathematicians

English translator of the first article about Babbage's Analytical Engine, written by Luigi Federico Menabrea in French

She enriched the English translation of the article with several annotations

Original article: ~8000 words

Notes by Ada: additional ~19000 words

Ada's heritage

First mechanical computer programmer: in the article notes, there is a description of how to use the Analytical Engine to calculate the Bernoulli numbers

The operating mechanism can even be thrown into action independently of any object to operate upon (although of course no result could then be developed). Again, it might act upon other things besides number, were objects found whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine. Supposing, for instance, that the fundamental relations of pitched sounds in the science of harmony and of musical composition were susceptible of such expression and adaptations, the engine might compose elaborate and scientific pieces of music of any degree of complexity or extent.

Science of Operations = Computer Science

Common features

What do recipes and instructions for assembling objects have in common?

Shared abstract notion: step-by-step procedure for producing something starting from some initial material we have = algorithm

Algorithm

The word algorithm is a combination of the Latin word algorismus (that is the Latinization of the name Al-Khwarizmi, who was a great mathematician from Persia in the 8th century) and the Greek word arithmos, meaning number

Each algorithm is written in a specific language which is functional to communicate its instruction to a computer

Computer programmer: anyone that creates algorithms that can be interpreted by any computer

Pseudocode

A pseudocode in an informal language that could be interpreted easily by any computer - even if, usually, it is pretty close to a programming language

It is used by Computer Scientists for sketching an algorithm before to implement it in a particular programming language

Checking if an algorithm can be interpretable by a computer: provide a colleague with the pseudocode of the algorithm and ask her to execute it using a particular input, writing down all the passages of the execution on a piece of paper

Flowchart

In this lecture, though, we use a particular graphical alternative to a common pseudocode which is good for being understandable by humans: a flowchart

Our first algorithm: taking in input three different strings, i.e. two words and a bibliographic entry of a published paper, return 2 if both the words are contained in the bibliographic entry, 1 if at least one of the words is contained in the bibliographic entry, and 0 otherwise

E.g.: input "Berners-Lee", "web" and "Tim Berners-Lee: Designing the web for an open society. WWW 2011: 3-4"; output 2.

Flowchart: flowline

The arrow is used to define the order in which the operations are executed

The flow indicated by the arrows begin in the starting terminal and ends in the ending terminal

Flowchart: terminal

It indicates the beginning and ending of an algorithm

It contains a text (usually, either "start" or "end") so as to disambiguate which role has the particular terminal widget in the context of the algorithm

Flowchart: input / output

It allows one to specify possible input / output material which is used / returned by the algorithm usually at the beginning or end of its execution

Flowchart: decision

It depicts a conditional operation, where a condition is checked and, depending on the value of some of the variables involved in the algorithm, the execution continues in a particular branch instead of another

Usually, the this operation creates two possible alternative branches: one to be followed whether the condition considered is true, and the other in case the condition is false

Partial algorithm

Take in input only two strings, i.e. an input word and a bibliographic entry, and return 1 if the the input word is contained in the bibliographic entry, otherwise return 0

Partial algorithm

Take in input only two strings, i.e. an input word and a bibliographic entry, and return 1 if the the input word is contained in the bibliographic entry, otherwise return 0

Partial algorithm

Take in input only two strings, i.e. an input word and a bibliographic entry, and return 1 if the the input word is contained in the bibliographic entry, otherwise return 0

Partial algorithm

Take in input only two strings, i.e. an input word and a bibliographic entry, and return 1 if the the input word is contained in the bibliographic entry, otherwise return 0

Partial algorithm

Take in input only two strings, i.e. an input word and a bibliographic entry, and return 1 if the the input word is contained in the bibliographic entry, otherwise return 0

Flowchart: process

It is used for expressing (usually one) instruction or operation, that is executed and that can change the current state of some variables used in the algorithm

The text it includes depicts the instruction to execute

Final algorithm: reprise

Take in input three different strings, i.e. two words and a bibliographic entry of a published paper, and return 2 if both the words are contained in the bibliographic entry, 1 if at least one of the words is contained in the bibliographic entry, and 0 otherwise

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

Final algorithm: flowchart

How to create flowcharts

Old-fashioned method: use a piece of paper plus either a pencil or pen - it works, I swear

Modern method: there exists also online tools that allow you to create a flowchart by using an (electronic) computer - e.g. the one that has been used to create all the diagrams in this lecture is called Draw.io, which is a free-to-use Web application with a nice graphical user interface

END Algorithms