2018-2019
2018-2019 copied to clipboard
Lecture "Algorithms", exercise 3
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.
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
I'm not sure about the graphical representation of recursion in the second flowchart!
EDIT: added the ending terminals
I'll come back later to add other solutions that I was thinking of.
![]()
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. 💃
Curious to hear what you guys think of this first way, making the algorithm save f(0) and f(1) to later retrieve them:
and then a, b, c way similar to others'
It is necessary to define f before addressing the function. Here: Fib(int n)
Sidenote: The second paragraph was difficult to understand because it is not clear what "the same function" means.
Applying recursion:
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.