comp-think / 2018-2019

The GitHub repository containing all the material related to the Computational Thinking and Programming course of the Digital Humanities and Digital Knowledge degree at the University of Bologna (a.a. 2018/2019).
Other
30 stars 8 forks source link

Lecture "Algorithms", exercise 3 #6

Open essepuntato opened 5 years ago

essepuntato commented 5 years ago

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.

MattiaSpadoni commented 5 years ago

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

mangiafrangette commented 5 years ago

algorithms3a

algorithms3b

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

EDIT: added the ending terminals

friendlynihilist commented 5 years ago

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

friendlynihilist commented 5 years ago

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. 💃

simayguzel commented 5 years ago

untitled diagram

lisasiurina commented 5 years ago

untitled diagram 1

MilenaCorbellini commented 5 years ago

untitled diagram diagram 2

EleonoraPeruch commented 5 years ago

algorithms-exercise 3a

algorithms-exercise 3b

delfimpandiani commented 5 years ago

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
Ioanna96 commented 5 years ago

untitled diagram 2 untitled diagram 1

andreamust commented 5 years ago

untitled diagram 2

SeverinJB commented 5 years ago

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.

ilsamoano commented 5 years ago

3 issue flowchart 1 3 issue flowchart 2

tceron commented 5 years ago

function f1

Applying recursion: function f2

essepuntato commented 5 years ago

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.