Answer
The algorithm produced by the student would work, provided that all three
of the numerical values are different. This could be solved by using the
"more or equal" sign. It is still inefficient. We only need 2 comparisons.
Input: $x, y, z$
Output: Largest
Algorithm:
Step 1 Check if $(x \geq y) .$ If yes, go to Step $2,$ otherwise to Step $3 .$
Step 2 Check if $(x \geq z) .$ If yes then Largest $=x .$ Otherwise Largest $=z$ .
Step 3 Check if $(y \geq z)$ . If yes then Largest $=y .$ Otherwise Largest $=z$ .
Step 4 Print out the Largest.
Work Step by Step
The algorithm produced by the student would work, provided that all three
of the numerical values are different. This could be solved by using the
"more or equal" sign. This way, when comparing 2 equal numbers, any of
them could be used for the other comparison, since the value would be the
same. The problem, however, is that it would still be too long. We should be
able to find the largest number by performing no more than 2 comparisons.
Here is what a better solution would be:
Input: $x, y, z$
Output: Largest
Algorithm:
Step 1 Check if $(x \geq y) .$ If yes, go to Step $2,$ otherwise to Step $3 .$
Step 2 Check if $(x \geq z) .$ If yes then Largest $=x .$ Otherwise Largest $=z$ .
Step 3 Check if $(y \geq z)$ . If yes then Largest $=y .$ Otherwise Largest $=z$ .
Step 4 Print out the Largest.