ERASE FUNCTION IMPLEMENTATION ISSUE

hello m facing dfficulty in coding the erase function for a hashfunction…could u please explain it?

Hello @sneha23 see this :
void erase(string key){
int idx=hashfun(key);
Node*temp=table[idx];
Node*prev=NULL;
while(temp){
if(temp->key==key){
if(prev)prev->next=temp->next;
else table[idx]=temp->next;
temp->next=NULL;
delete temp;
}
prev=temp;
temp=temp->next;
}
}
this is teh erase function:
if you have any doubt in this ;
you can ask here:
Happy learning!!