# Hash sets

In many algorithms, it is necessary to perform operations on sets with various data. However, what is a **set**? **A set is a collection of distinct objects without duplicated elements and without a particular order.** Therefore, you can only get to know whether a given element is in the set or not. These sets are strictly connected with mathematical models and operations, such as union, intersection, subtraction, and symmetric difference. A set can store various data, such as integer or string values. Of course, you can also create a set with instances of a user-defined class or record, as well as add and remove elements from the set at any time.

Imagine a hash set

If you want to better visualize a hash set, think for a moment about the game of chance, which is popular in many countries and involves selecting a few numbers that are then drawn from among many available ones. Depending on how many numbers you got from those drawn, you receive a prize. Of course, the chance of...