Deskripsi untuk soal nomor 40 - 41
Perhatikan potongan algoritma berikut.
var
a: array[1..8] of integer = (12, 30, 21, 8, 6, 9, 1, 7);
procedure zz(i: integer; j: integer);
var tmp: integer;
begin
tmp := a[i]; a[i] := a[j]; a[j] := tmp;
end;
var
h,k,val: integer;
begin
val := a[1];
h := 1;
for k := 2 to 8 do begin
if (a[k] < val) then begin
h := h + 1;
zz(h,k);
end;
end;
zz(1,h);
end.
Berapa kalikah zz() dijalankan dalam eksekusi algoritma tersebut?
a. 10
b. 5
c. 2
d. 6
e. 8
Berapakah isi array a setelah algoritma ini dijalankan?
a. (12, 30, 21, 8, 6, 9, 1, 7)
b. (1, 6, 7, 8, 9, 12, 21, 30)
c. (30, 21, 12, 9, 8, 7, 6, 1)
d. (1, 30, 6, 21, 7, 12, 8, 9)
e. (7, 8, 6, 9, 1, 12, 21, 30)