Improvement I
Remove the reduction from the loop
- Assume positive elements for simplicity ...
Count := 0; -- Initialize
for i := 1 to n do -- Sweep thru all S
Count += S = >>[i]S; -- Record Occurrences
end;
most := max<< S; -- Figure the best?
mode := max<<((most = Count)*S);
-- Isolate the mode
Performance ...
- n single element broadcasts + local; no early exit
- 2 reductions + local