Basic question about set theory
I apologize for having to ask this question, but I would like to know if there is a definitive answer or not. Are sets allowed to contain duplicate elements? When I took computer science theory, the Professor said the usual view was that sets can contain multiple elements. The textbook, however, stated that a set is not a set if it contains duplicate elements.
Can you tell me which is the correct answer, and why?
Sets don't contain duplicate elements by definition. A multiset, however, may contain more than one instance of the same element.
Also, if you consider a sequence of objects rather than a set of objects, the elements of the sequence need not be unique. The situation is similar for tuples. Of course, in sequences and tuples order matters, but order does not matter in sets and multisets.
In computer science, there is the bag ADT, which is just about the most loose and unrestricted data collection you can have: it's unordered and may contain duplicates, so it's similar to a multiset.
Also, if you consider a sequence of objects rather than a set of objects, the elements of the sequence need not be unique. The situation is similar for tuples. Of course, in sequences and tuples order matters, but order does not matter in sets and multisets.
In computer science, there is the bag ADT, which is just about the most loose and unrestricted data collection you can have: it's unordered and may contain duplicates, so it's similar to a multiset.
The point is that the only thing that characterize sets is the "belongs to" symbol ∈. All that matters is whether an element is part of a set or not. Order and duplicates are not accounted for.
For example, you have that the two following sets are equal
{1, 2, 2, 3} = {3, 2, 1}
Because both of these sets have the property that 1 ∈ the set, 2 ∈ the set, 3 ∈ the set, and finally for any element x which is different from 1, 2 and 3, then x is not in the set.
For example, you have that the two following sets are equal
{1, 2, 2, 3} = {3, 2, 1}
Because both of these sets have the property that 1 ∈ the set, 2 ∈ the set, 3 ∈ the set, and finally for any element x which is different from 1, 2 and 3, then x is not in the set.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement