Ejemplo n.º 1
0
int main()
{
	ifstream fin;
	string word;
	HashTable Table;
	fin.open("jumbledwords.txt");
	fin >> word;
	while(!fin.fail()){
		Table.insert(word);
		fin >> word;
	}
	fin.close();
	for (int i = 0; i < Table.getSize(); i++) {
		if (Table.clusterLength(i) > 1) {
			cout << "index " << i << "  " << Table.clusterLength(i) << endl;
		}
	}
	cout << Table.getSize();
	return 0;
}
int countCollisions(const HashTable<Movie>& table) {
    int tableSize = table.getSize();
    int chainSize = 0;
    int collisions = 0;

    while (tableSize-- > 0) {
        chainSize = table.getChainSize(tableSize);
        if (chainSize) collisions += (chainSize - 1);
    }

    return collisions;
}