-- Mar 4 In-Class Exercise
Blocks hold 3 records
Records hold 1 integer
Memory is 3 blocks big (2 available buckets)
Hash Function is mod 2
Integer ... Mod 2
1 1
2 0
3 1
Eliminate the duplicates from
indexes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3
hashes 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1
1 is hashed to bucket1(1)
2 is hashed to bucket0(2)
3 is hashed to bucket1(1,3)
1 is hashed to bucket1(1,3,1)
Bucket1(1,3,1) is placed in disk >>>>>> (1,3,1)
2 is hashed to bucket0(2,2)
3 is hashed to bucket1(3)
1 is hashed to bucket1(3,1)
2 is hashed to bucket0(2,2,2)
Bucket0(2,2,2) is placed in disk>>>>>>> (2,2,2)
3 is hashed to bucket1(3,1,3)
Bucket1(3,1,3) is placed in disk >>>>> (1,3,1,3,1,3)
1 is hashed to bucket1(1)
2 is hashed to bucket0(2)
3 is hashed to bucket1(1,3)
Bucket0 combines to (2,2,2,2)
Bucket1 combines to (1,3,1,3,1,3,1,3)
read bucket0 into memory, eliminate 2,2,2
Bucket 0 finally ends up as (2)
read bucket1 into memory, eliminate 1,1,1,3,3,3
Bucket 1 finally ends up as (1,3)
(
Edited: 2020-03-04)
Blocks hold 3 records
Records hold 1 integer
Memory is 3 blocks big (2 available buckets)
Hash Function is mod 2
Integer ... Mod 2
1 1
2 0
3 1
Eliminate the duplicates from
indexes 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3
hashes 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1
1 is hashed to bucket1(1)
2 is hashed to bucket0(2)
3 is hashed to bucket1(1,3)
1 is hashed to bucket1(1,3,1)
Bucket1(1,3,1) is placed in disk >>>>>> (1,3,1)
2 is hashed to bucket0(2,2)
3 is hashed to bucket1(3)
1 is hashed to bucket1(3,1)
2 is hashed to bucket0(2,2,2)
Bucket0(2,2,2) is placed in disk>>>>>>> (2,2,2)
3 is hashed to bucket1(3,1,3)
Bucket1(3,1,3) is placed in disk >>>>> (1,3,1,3,1,3)
1 is hashed to bucket1(1)
2 is hashed to bucket0(2)
3 is hashed to bucket1(1,3)
Bucket0 combines to (2,2,2,2)
Bucket1 combines to (1,3,1,3,1,3,1,3)
read bucket0 into memory, eliminate 2,2,2
Bucket 0 finally ends up as (2)
read bucket1 into memory, eliminate 1,1,1,3,3,3
Bucket 1 finally ends up as (1,3)