return to all data-structures
return to concepts
The Set Data Structure
Overview
- Similar concept to the sets from set theory (a subset of discrete mathematics).
- Only contains unique items; no duplicates allowed.
- This rule is enforced as data is added to the list.
- Uses a hash function to achieve constant lookup time
When to Use Sets
- When you need unique data.
- Remember, it prevents duplicates from being added.
Time Complexity
Operation |
Average Time Complexity |
Insert |
O(1) |
Delete |
O(1) |
Traversal |
O(n) |
return to all data-structures
return to concepts