Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bloom filter in Java

Basically I have to implement a bloom filter and test it with char 'a' to 'z' and 'A' to 'Z' (easy and done).

Then I have to test for false positives but the requirements say to use "aa" to "ZZ" (strings) to count the false positives (not done).

Any idea what that means?

like image 446
Bill Avatar asked Jun 25 '11 19:06

Bill


1 Answers

false positive requires actual set of data, I think what your professor meant was: add 'a'-'z','A'-'Z' to the filter (actual data) now, check for all the strings "aa"-"ZZ", count the number of false positives (all positives will be false, since none of them are in the data) and extract the ratio: #false_positives/#strings_in_range("aa","ZZ")

EDIT: at comments @Bill asked how to iterate over "aa"-"ZZ", here is a simple code snap of how to do it.

Set<String> set = new HashSet<String>();
for (Character c = 'a';c<='z';c++) { 
     String lower = c.toString();
     String upper = c.toString().toUpperCase();
     for (Character k = 'a';k<='z';k++) { 
            set.add(lower + k.toString());
            set.add(lower + k.toString().toUpperCase());
            set.add(upper + k.toString());
            set.add(upper + k.toString().toUpperCase());
     }
}
like image 103
amit Avatar answered Sep 30 '22 00:09

amit