2018-2019 icon indicating copy to clipboard operation
2018-2019 copied to clipboard

Lecture "Algorithms", exercise 3

Open essepuntato opened this issue 6 years ago • 15 comments

The previous lecture notes, entitled “Introduction to Computational Thinking”, illustrate two different algorithms, expressed in natural language, for implementing the Fibonacci function. Create two distinct flowcharts so as to implement both of them.

essepuntato avatar Nov 14 '18 06:11 essepuntato

I try, but I'm not so sure about something. Ah, above the line there is the first algorith, under the line the second.

P.S. I've forgotten some "no" along the flowchart

diagram ex 3

MattiaSpadoni avatar Nov 14 '18 16:11 MattiaSpadoni

algorithms3a

algorithms3b

I'm not sure about the graphical representation of recursion in the second flowchart!

EDIT: added the ending terminals

mangiafrangette avatar Nov 14 '18 17:11 mangiafrangette

I'll come back later to add other solutions that I was thinking of. fibonacci1 2

friendlynihilist avatar Nov 14 '18 17:11 friendlynihilist

algorithms3a algorithms3b I'm not sure about the graphical representation of recursion in the second flowchart!

I think you need to add two ending terminals! Love you anyway. 💃

friendlynihilist avatar Nov 14 '18 17:11 friendlynihilist

untitled diagram

simayguzel avatar Nov 14 '18 22:11 simayguzel

untitled diagram 1

lisasiurina avatar Nov 14 '18 22:11 lisasiurina

untitled diagram diagram 2

MilenaCorbellini avatar Nov 15 '18 10:11 MilenaCorbellini

algorithms-exercise 3a

algorithms-exercise 3b

EleonoraPeruch avatar Nov 15 '18 16:11 EleonoraPeruch

Curious to hear what you guys think of this first way, making the algorithm save f(0) and f(1) to later retrieve them: fibonacci 2

and then a, b, c way similar to others' fibonacci 1

delfimpandiani avatar Nov 15 '18 16:11 delfimpandiani

untitled diagram 2 untitled diagram 1

Ioanna96 avatar Nov 15 '18 18:11 Ioanna96

untitled diagram 2

andreamust avatar Nov 15 '18 20:11 andreamust

algorithms_exercise_3a

It is necessary to define f before addressing the function. Here: Fib(int n) algorithms_exercise_3b 1

Sidenote: The second paragraph was difficult to understand because it is not clear what "the same function" means.

SeverinJB avatar Nov 15 '18 21:11 SeverinJB

3 issue flowchart 1 3 issue flowchart 2

ilsamoano avatar Nov 16 '18 10:11 ilsamoano

function f1

Applying recursion: function f2

tceron avatar Nov 17 '18 17:11 tceron

Hi all,

thanks for all the proposed solutions, that look correct to a first sight. Indeed, representing the recursive step with a flowchart could be tricky, but I really liked the simplicity of the approach that have been proposed in your diagrams.

essepuntato avatar Nov 19 '18 06:11 essepuntato