Using eclipse and this code:
write a hasCluster() method to check if there is a cluster in the hash table or no,, if yes return true?
code:public class LinearProbingHashTable { private Student[] hashArray; // array holds hash table private int arraySize; private Student defunct; // for deleted items private int size; // ------------------------------------------------------------- public LinearProbingHashTable(int size) // constructor { arraySize = size; hashArray = new Student[arraySize]; defunct = new Student(-1,"null",0); // deleted item key is -1 } // ------------------------------------------------------------- public void displayTable() { System.out.print("Table: "); for(int j=0; j=0.5) rehash(); if (!isFull()) { int key = s.getId(); // extract key int hashVal = hashFunc(key); // hash the key while(hashArray[hashVal] != null && hashArray[hashVal]!= defunct) { ++hashVal; // go to next cell hashVal %= arraySize; // wraparound if necessary } hashArray[hashVal] = s; // insert item size++; } }// end insert() // ------------------------------------------------------------- public Student delete(int key) // delete a DataItem { int hashVal = hashFunc(key); // hash the key int start=hashVal; boolean checkAll=false; while(hashArray[hashVal] != null && !checkAll) { if(hashArray[hashVal].getId() == key) { Student temp = hashArray[hashVal]; // save item hashArray[hashVal] = defunct; // delete item size--; return temp; // return item } ++hashVal; // go to next cell hashVal %= arraySize; // wraparound if necessary if (hashVal==start) // if we compare all and go back to the same start index checkAll=true; } return null; // can't find item } // end delete() // ------------------------------------------------------------- public Student find(int key) // find item with key { int hashVal = hashFunc(key); // hash the key int start=hashVal; boolean checkAll=false; while(hashArray[hashVal] != null && !checkAll) // until empty cell, { // found the key? if(hashArray[hashVal].getId() == key) return hashArray[hashVal]; // yes, return item ++hashVal; // go to next cell hashVal %= arraySize; // wraparound if necessary if (hashVal==start) // if we compare all and go back to the same start index checkAll=true; } return null; // can't find item } // ------------------------------------------------------------- public void rehash() { Student tmp[]=hashArray; arraySize*=2; hashArray=new Student[arraySize]; for (int i=0;i