August 2024
Intermediate to advanced
516 pages
11h 47m
English
Let’s explore this other data structure: the set. A set is a data structure that does not allow duplicate values to be contained within it.
Sets are of different types, but for this discussion, I’ll talk about an array-based set. This set is just like an array—it’s a simple list of values. The only difference between this set and a classic array is that the set never allows duplicate values to be inserted into it.
For example, if you had the set [’a’, ’b’, ’c’] and tried to add another ’b’, the computer just wouldn’t allow it, since a ’b’ already exists within the set.
Sets are useful when you need to ensure that you don’t have duplicate data.
For instance, if you’re creating an online phone book, ...
Read now
Unlock full access