SAC
EXAMPLE
8
Example a Simple
Search Algorithm; Selection Nested within Iteration
(
NOTE:
This does not implement the OOSD paradigm; see the last extension.)
The following SAC represents the algorithm of
a
simple search algorithm. (NOTE: This
algorithm is far from perfect; extensions 2 - 5 (following the
illustration)
show how it can be optimized.)

EXTENSIONS:
-

Develop a simple
decending sort algorithm ( i.e. largest first) that searches through an array of
integers to find the maximum value in the unsorted part of the array
and then, if it is larger than the current maximum value, swap
the values. For example an unsorted array with values
3,1,2,4,2 would be sorted into 4,3,2,2,1.
-

How
would the algorithms in this example be modified to represent OOSD?
(b) Would the different versions of this algorithm have different OOSD
versions?
SAQ
1: