UnorderedSet Visualizer
Set with separate chaining - no duplicates, no ordering
Hash Function with Separate Chaining
hash(value) = (Σ value[i] × 31) % 6
Collisions resolved by chaining - duplicates automatically prevented
UnorderedSet Operations:
Basic Operations:
- insert(value): Add value to set (ignores duplicates)
- find(value): Check if value exists in set
- erase(value): Remove value from set
- size(): Get number of elements in set
- empty(): Check if set is empty
Set Operations:
- Union: Combine elements from multiple sets
- Intersection: Find common elements
Characteristics:
- No Duplicates: Each element appears at most once
- Unordered: No specific ordering of elements
- Average Time: O(1) for insert, find, erase
- Worst Case: O(n) when all elements hash to same bucket
- Space: O(n) for elements + O(b) for buckets
- Use Cases: Membership testing, removing duplicates, set operations
C++ STL Context: unordered_set is the hash table implementation of a set, while std::set uses a balanced binary search tree (red-black tree). Use unordered_set when you need fast average-case performance and dont need ordered iteration.