Can you please explain how the delete operator is working in the execution of hashing?
Delete operator
To be precise, I want to know how the delete operator is working in the destructor.
@sr30
When you delete the hashtable, you need to delete the bucket array and linked lists inside each bucket. So first you call delete on the Linked List which recursively frees nodes from last to first. After that you use delete to delete the linked list pointer array ( bucket array ). Now every dynamic part of vector has been deleted. You can start making new one in its place.
If your doubt is resolved please mark it as closed.
I am unable to understand how delete next is able to free all the nodes of the linked list associated to that specific bucket.
Is it the inbuilt functionality of delete operation to start freeing all the nodes from the last node?
@sr30
See the way delete is implemented. It is a recursive function that we have made. When we get a request to delete a node, we first send a request to next node to delete itself, then we delete ourselves.
Okay. I got it. Thanks.