Question: void ComputedChaining::insert ( int key ) { int index = hash ( key ) ; if ( data _ vec [ index ] . data

void ComputedChaining::insert(int key){
int index=hash(key);
if(data_vec[index].data !=-1){//collision
if(isThisYourHome(data_vec[index].data)){//Q1: Add to chain
//Your code here
}else{//collision move foreigners
//store the key that will be moved(moved_key)
//find the chain of the moved_key
//find the index of moved_key in the chain
//store the previous index of the moved_key to change the link of the entry
//store the keys after moved_key in the chain
//assign -1 to indexes of data_vec where moved_key and remaining -1
//insert new key to its original address
//recursively insert remaining of the chain
}
}else{//direct insertion
data_vec[index].data = key;
data_vec[index].link=-1;
}
}
 void ComputedChaining::insert(int key){ int index=hash(key); if(data_vec[index].data !=-1){//collision if(isThisYourHome(data_vec[index].data)){//Q1: Add to chain

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!