Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // all elements are integers in range a to b
- a = ...
- b = ...
- table = new Array(size: b - a, default: 0)
- // add items to the table
- for item in stream {
- table[item]++
- }
- // find the mode by sorting the table keys by their values
- mode = range(a, b).sortBy(item => table[item])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement