Abstract Data Structure (2)

BY IN IB Computer Science Comments Off on Abstract Data Structure (2)

function CHECK( DATA integer array [1..8])
result boolean
declare POS, COUNT integer
COUNT= 0
for POS = 1 to 8 do
  If DATA[POS] = 1 then
    COUNT = COUNT+1
  endif
endfor
return (COUNT mod 2)=0
endfunction CHECK

Data:
0 1 1 1 0 1 1 0

Answer:

The function CHECK will return FALSE

Data:
1 1 0 0 1 0 1 0

Answer:

The function CHECK will return TRUE




Comments are closed.