@Override
	public void addWord(String word) {

		if (Math.random() <= Math.pow(2., -h)) {
			MyString str = new MyString(word);
			Integer i = sample.get(str);
			
			if (i == null) sample.put(str, 1);
			else 		   sample.put(str, 1 + i.intValue());
			
			sumK++;
		}
		
		if(sumK == Math.pow(2., b)){
			h++;
			RandomDataGenerator rand = new RandomDataGenerator();
			Iterator<MyString> it = sample.keySet().iterator();
			while(it.hasNext()){
				MyString s = it.next();
				int ks = sample.get(s);
				sumK -= ks;
				int k = rand.nextBinomial(ks, 0.5);
				if(k != 0){
					sample.put(s, k);	
					sumK += k;
				}
				else
					it.remove();
			}
		}
		
	}