comp-think/2019-2020

Lecture "Algorithms", exercise 2

Opened this issue · 14 comments

Write the flowchart of an algorithm that takes in input two objects and returns the string "yes" whether the two objects are the same; otherwise, it returns the string "no".

a809 commented

exercise 2 jpeg

Hi all,

Thanks for the solution proposed. Looking at your diagrams, I've seen a bunch of mistakes that should be better to address as soon as possible. Following a random order:

  1. When you have to return something using the input/output widget, you have to explicitly write that you are returning (e.g. writing return "yes" instead of just "yes"). This is important since the widget can be used either for input or for output and it is impossible to disambiguate the intended usage without a text that clarifies it. In fact, even if we will specify the input only at the very beginning of the algorithm, there may exist some situation (that we do not analyse in our course) where a user is required to provide different inputs in different position of the algorithm. Thus, please specify every time if you are using the input/output widget as input or as output.

  2. Please read carefully the natural language description of the algorithm and, in particular, identify the input and output. Some of you have returned a number instead of a string. In the past years, I've seen projects failing just for having not respected the particular output that an algorithm should return.