Solution for erase H/W

Please help with the solution for the erase Node homework. I am able to replicate the O(n) function via simple modification to the rehash() function. Please let me know if there is a much simpler approach.

My code (failed erase) is at : https://ide.codingblocks.com/s/106089

@Sriram-Rajan-10104264111174086
Sorry for the extremely late reply.
Update your if condition inside the erase function to this
if (temp->key == key) {
buckets[i] = buckets[i]->next;
temp->next = NULL ;
delete(temp);
cs–;
return ;
}

You are getting invalid output as your code deletes temp and goes on to delete the entire bucket thereafter as your node constructor is defined that way. We need to change the next pointer of temp to prevent the entire list from getting deleted.

@tarunluthra Thanks for the tip. But the issue still exists in the updated code on erasing “Kiwi”.

Please take a look.

@Sriram-Rajan-10104264111174086
I have only made the modifications I suggested above. The code seems to be working fine to me. Could you please describe the issue you are facing in more detail.
This is my code - https://ide.codingblocks.com/s/109440