I am unable to implement erase function can I get some hint to implement erase function in hashtable
Hashtable erase function
First, implement your search function and send it to me. I’ll then explain how it is similar and what all you need to change.
I have implemented the serach function now what changes i have to make to implement erase function
Check this code, I just added the erase and printed.
In the erase function firstly we have deleted key in the if statement then why we are same code in the while loop below the if statement
The if statement is only to handle the case when the element to be deleted is at the head of the linkedlist.
You can read about deletion in linkedlists, for more details.
can we code the erase function like this
Noo! Not always.
It is possible that the key you are looking for is not at the head, so you need to iterate (As we do in search) and find that particular key.