Information Technology Reference
In-Depth Information
SXEOLFVWDWLFYRLGVHOHFWLRQ6RUWLQW>@DUU^
LQWSWHPS
IRULQWL LDUUOHQJWKL^
S L
IRULQWM LMDUUOHQJWKM^
LIDUU>M@DUU>S@
S M
`
LIS L^
WHPS DUU>L@
DUU>L@ DUU>S@
DUU>S@ WHPS
`
`
`
Answer the following questions and explain your answers:
1. Will the algorithm correctness be effected if the instruction marked by (2)
is removed and the instruction marked by (3) is replaced with the following
instruction:
(3) for (  int j = i; j < arr.length; j + + ) {
2. Will the algorithm correctness be affected if the instruction marked by (4) is
removed and the contents of the two array elements are swapped anyway?
3. Will the algorithm correctness be affected if all the body of the loop marked by
(3) is replaced with the following instructions?
IRULQWM LMDUUOHQJWKM^
Variations : An “instruction manipulations” question can be implemented by the
(a) addition of instructions; (b) removal of instructions; (c) changing instructions;
(d) replacement of instructions. The question itself can address the target of a spe-
cific code or the tracing of the changed code and the examination of differences
between outputs.
Discussion : Questions that manipulate a given solution enable to concentrate on
meaningful aspects of the algorithm. In the teaching process, a discussion on such
manipulations can clarify the essence of a given solution as well as other CS topics.
We illustrate this idea by the concept of generalization. Students can be instructed
to change a given method slightly, in a way that generalizes the original method
and solves a broader task. For example, a method that sorts an array can be slightly
changed in order to sort a section of the array between two given indices. After the
change, the method can sort different sections of an array, as well as the entire array
(with the indices 0 and the array length—1).
Search WWH ::




Custom Search