Question: ~ Consider the following sort routine: procedure selectsort(var r: array [1 .. n] of integer); var j, k, small: integer; begin if n > 1
~ Consider the following sort routine:
procedure selectsort(var r: array [1 .. n] of integer);
var j, k, small: integer;
begin if n > 1 then for k:= 1 to n - 1 do small:= k;
for j:= k + 1 to n do if r[j] < r[small] then small:= j end end;
swap(r[k], r[small])
end end end selectsort;
Determine the function (by means of pre- and postconditions) of this routine using stepwise abstraction.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
