diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..07115cdf15dd408d3affb9240e112578e04abf68
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..187678b5261f2989f50ceda3a9b78baa9ef77e0d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2b63946d5b31084bbb7dda418ceb3d75eb686373
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index bb16a034f94a7c6d7057b252004c5760b755246a..063dceac91a9612b571c40d4e5174dd62a67a092 100644
--- a/README.md
+++ b/README.md
@@ -1,93 +1 @@
-# hw2p2
-
-
-
-## Getting started
-
-To make it easy for you to get started with GitLab, here's a list of recommended next steps.
-
-Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
-
-## Add your files
-
-- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
-- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
-
-```
-cd existing_repo
-git remote add origin https://agile.bu.edu/gitlab/ec504/hw2/hw2p2.git
-git branch -M master
-git push -uf origin master
-```
-
-## Integrate with your tools
-
-- [ ] [Set up project integrations](https://agile.bu.edu/gitlab/ec504/hw2/hw2p2/-/settings/integrations)
-
-## Collaborate with your team
-
-- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
-- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
-- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
-- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
-- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
-
-## Test and Deploy
-
-Use the built-in continuous integration in GitLab.
-
-- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
-- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
-- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
-- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
-- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
-
-***
-
-# Editing this README
-
-When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
-
-## Suggestions for a good README
-
-Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
-
-## Name
-Choose a self-explaining name for your project.
-
-## Description
-Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
-
-## Badges
-On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
-
-## Visuals
-Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
-
-## Installation
-Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
-
-## Usage
-Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
-
-## Support
-Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
-
-## Roadmap
-If you have ideas for releases in the future, it is a good idea to list them in the README.
-
-## Contributing
-State if you are open to contributions and what your requirements are for accepting them.
-
-For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
-
-You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
-
-## Authors and acknowledgment
-Show your appreciation to those who have contributed to the project.
-
-## License
-For open source projects, say how it is licensed.
-
-## Project status
-If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+# Homework Two, problem 2
\ No newline at end of file
diff --git a/hw2p2.iml b/hw2p2.iml
new file mode 100644
index 0000000000000000000000000000000000000000..c90834f2d607afe55e6104d8aa2cdfffb713f688
--- /dev/null
+++ b/hw2p2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/edu/bu/ec504/hw2p2/BloomFilter.java b/src/edu/bu/ec504/hw2p2/BloomFilter.java
new file mode 100644
index 0000000000000000000000000000000000000000..dbdcb48dd66578e4a6aec34b6952443f6681d189
--- /dev/null
+++ b/src/edu/bu/ec504/hw2p2/BloomFilter.java
@@ -0,0 +1,41 @@
+package edu.bu.ec504.hw2p2;
+
+import edu.bu.ec504.hw2p2.hashing.HashFamily;
+
+/**
+ * Implements a Bloom filter
+ */
+public class BloomFilter {
+ // CONSTRUCTORS
+
+ BloomFilter(HashFamily theHashFamily) {
+ storedHF = theHashFamily;
+ filter = new boolean[storedHF.getRange()]; // the filter itself
+ }
+
+ void insert(int element) {
+ for (int ii = 0; ii< storedHF.getNumHashes(); ii++)
+ filter[ storedHF.apply(ii, element) ] = true;
+ }
+
+ // METHODS
+ boolean inFilter(int element) {
+ for (int ii = 0; ii < storedHF.getNumHashes(); ii++)
+ if (!filter[storedHF.apply(ii, element)])
+ return false;
+
+ return true;
+ }
+
+ // FIELDS
+
+ /**
+ * The Bloom filter array.
+ */
+ private final boolean[] filter;
+
+ /**
+ * A stored version of the {@link HashFamily} used by this Bloom Filter.
+ */
+ private final HashFamily storedHF;
+}
diff --git a/src/edu/bu/ec504/hw2p2/Main.java b/src/edu/bu/ec504/hw2p2/Main.java
new file mode 100644
index 0000000000000000000000000000000000000000..35ce2ce06169580dd94aca3c6bfe37ca39a993c6
--- /dev/null
+++ b/src/edu/bu/ec504/hw2p2/Main.java
@@ -0,0 +1,45 @@
+package edu.bu.ec504.hw2p2;
+
+import edu.bu.ec504.hw2p2.hashing.HashFamily;
+import edu.bu.ec504.hw2p2.hashing.MyHashFamily;
+import edu.bu.ec504.hw2p2.hashing.SimpleHashFamily;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+public class Main {
+ static int numTests=0; // the number of tests performed so far
+ static double sumFp=0.0; // a sum of the false positive values seen so far
+
+ public static void main(String[] args) {
+ // some simple tests of MyHashFamily
+ final int NUMH = 3; // the number of hashes in the family
+ final int RANGE = 10; // the range of each hash in the family
+ final int NUMI = 5; // the number of elements to insert into the Bloom Filter
+
+ // ... create a Bloom filter based on MyHashFamily with NUMH hashes in the range 0..RANGE-1
+ BloomFilter MyBF = new BloomFilter(new MyHashFamily(NUMH,RANGE));
+ // ... create a Bloom filter based on a SimpleHashFamily with NUMH hashes in the range 0..RANGE-1
+ BloomFilter SimpleBF = new BloomFilter(new SimpleHashFamily(NUMH, RANGE));
+
+ // ... populate the Bloom filters
+ for (int ii=0; iinumHashes hash functions, each mapping
+ * a given input onto integers in the range 0..range
-1, inclusive.
+ *
+ * @param numHashes The maximum number of hashes in the family.
+ * @param range Each hash maps input to the range 0..range
-1, inclusive.
+ */
+ public HashFamily(int numHashes, int range) {
+ myNumHashes = numHashes;
+ myRange = range;
+ }
+
+ // METHODS
+ // ... ACTION
+ /**
+ * Applies a requested hash function from this family to a specified parameter.
+ *
+ * @param index The index of the hash function to apply. Must be between 0 and {@link #myNumHashes}-1 inclusive.
+ * @param elem The element to hash.
+ * @return The evaluation of the index
th hash function in the family on element elem
.
+ */
+ public abstract int apply(int index, int elem);
+
+ // ... INFO
+ public int getNumHashes() { return myNumHashes; }
+ public int getRange() { return myRange; }
+
+
+ // FIELDS
+ private final int myNumHashes; // the number of hashes associated with this family
+ private final int myRange; // hashes in this family map to 0...range-1
+}
diff --git a/src/edu/bu/ec504/hw2p2/hashing/MyHashFamily.java b/src/edu/bu/ec504/hw2p2/hashing/MyHashFamily.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee42601cd475837815fa19dd4ede15f88e1cd2a2
--- /dev/null
+++ b/src/edu/bu/ec504/hw2p2/hashing/MyHashFamily.java
@@ -0,0 +1,29 @@
+package edu.bu.ec504.hw2p2.hashing;
+
+/**
+ * You should update this class's methods.
+ */
+public class MyHashFamily extends HashFamily {
+
+ /**
+ * Creates your hash family.
+ * @param numHashes The number of hashes in your hash family.
+ * @param range The range of each hash in your hash family.
+ */
+ public MyHashFamily(int numHashes, int range) {
+ super(numHashes, range);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public int apply(int index, int elem) {
+ // TODO: CHange this method
+ if (index<0 || index>getNumHashes())
+ throw new IndexOutOfBoundsException();
+
+ return 0;
+ }
+
+}
diff --git a/src/edu/bu/ec504/hw2p2/hashing/SimpleHashFamily.java b/src/edu/bu/ec504/hw2p2/hashing/SimpleHashFamily.java
new file mode 100644
index 0000000000000000000000000000000000000000..153d1b0e6e71048a96eda330c807bd68bc45221f
--- /dev/null
+++ b/src/edu/bu/ec504/hw2p2/hashing/SimpleHashFamily.java
@@ -0,0 +1,25 @@
+package edu.bu.ec504.hw2p2.hashing;
+
+/**
+ * An example of a simple hash family.
+ */
+public class SimpleHashFamily extends HashFamily {
+
+ /**
+ * @inheritDoc
+ */
+ public SimpleHashFamily(int numHashes, int range) {
+ super(numHashes, range);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ @Override
+ public int apply(int index, int elem) {
+ if (index<0 || index>getNumHashes())
+ throw new IndexOutOfBoundsException();
+
+ return elem%getRange();
+ }
+}