|
 |
 |
 |
 |
 |
 |
 |
Idea:
|
|
|
| |
Dont
keep an array of bins
|
|
|
| |
Instead,
place the occupied
|
|
|
bins
in a hash table
|
|
|
| |
Hash
on the bins array
|
|
|
|
indices
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
Result:
|
|
|
| |
Initialization
takes time O(n)
|
|
|
|
instead
of O(b)
|
|
|
| |
Still
fast to test whether q
|
|
|
|
falls
in an occupied bin
|
|
|
|
|
A
single test takes expected
|
|
|
time
O(1) instead of worst-
|
|
|
|
case
time O(1)
|
|
|
| |
Algorithm
now runs in
|
|
|
expected
time O(m2n)
|
|
|
instead
of worst-case time
|
|
|
|
O(b+m2n)
|
|
|
|