DSAHashingMembership

Is Subset Visualizer

What is a Subset Check

A is a subset of B when every value of A also exists in B. Hash B, then probe once per element of A. The first miss proves “not a subset”. If every probe hits, A ⊆ B.

  • Hash the universe: B is the allowed set.
  • Fail fast: one missing key is enough.
  • Multisets: if counts matter, compare frequencies instead of a plain set.

How this visualizer works

A = 1, 2, B = 1, 2, 3, 4. Both probes hit. Try A = 1, 5 to watch a miss.

Interactive trace

hash_table.state

Input
Hash table
Current look-up
Match / window
Stored entry

current_action

Load an input, then press Play or Step.

live_trace.py

1def isSubset(a, b):
2universe = set(b)
3for x in a:
4if x not in universe:
5return False
6return True

stdout — decision log

// each hash probe is recorded here
Speed Ready

Pseudocode & Complexity

idea.txt

1def isSubset(a, b):
2universe = set(b)
3for x in a:
4if x not in universe:
5return False
6return True

complexity.md

OperationTime
Build set(B)O(m)
Probe AO(n)
SpaceO(m)

Python implementation

solution.py

1def isSubset(a, b):
2 universe = set(b)
3 for x in a:
4 if x not in universe:
5 return False
6 return True