bagof/3 is is exactly the same as setof/3 except that the list (or alternative lists) returned will not be ordered, and may contain duplicates. This relaxation saves time and space in execution.
bagof/3
setof/3