A set object is an unordered collection of distinct hashable objects. It’s one of Python’s built-in types and allows the dynamic adding and removing of elements, iteration, and operations with another set objects.
A object is an unordered collection of distinct hashable objects. It’s one of Python’s built-in types and allows the dynamic adding and removing of elements, iteration, and operations with another set objects.
Sets are as fundamental to computer science as they are to mathematics. Sets manipulated by algorithms can grow, shrink, or otherwise change over time, we call such sets dynamic. Data structures present techniques for representing finite dynamic sets and manipulating them on a computer.
The best way to implement a dynamic set depends upon the operations that must be supported.
Can be grouped into two categories:
Queries, which simply return information about the set.
Modifying operations, which change the set.
SEARCH(S,k)
INSERT(S,x)
DELETE(S,x)
MINIMUM(S)
MAXIMUM(S)
SUCCESSOR(S,x)
PREDECESSOR(S,x)
Algorithms may require several different types of operations to be performed on sets. For example, many algorithms need only the ability to:
Insert elements into
Delete elements from
Test membership in a set.
We call a dynamic set that supports these operations a dictionary.
Other algorithms require more complicated operations, such as min-priority queues, which support the operation of inserting an element into and extracting the smallest element from a set.