Commit db5be436 by Krishnan Sanjay


parent 3c68f905
Showing with 0 additions and 50 deletions
''' defines a bloom filter which is an
approximate set membership data structure. You
will implement a full bloom filter in this module
import array
import binascii
import random
class Bloom(object):
def __init__(self, m,k, seed=0):
'''Creates a bloom filter of size m with k
independent hash functions.
self.array = array.array('B', [0] * m)
self.hashes = self.generate_hashes(m,k,seed)
def generate_hashes(self, m, k, seed):
'''Generate *k* independent linear hash functions
each with the range 0,...,m.
m: the range of the hash functions
k: the number of hash functions
seed: a random seed that controls which A/B linear
parameters are used.
The output of this function should be a list of functions
raise ValueError('Not Implemented')
def put(self, item):
'''Add a string to the bloom filter, returns void
def contains(self, item):
'''Test to see if the bloom filter could possibly
contain the string (true (possibly)), false (definitely).
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment