how does delete oldtable[i] deletes the head of the linked list?
Doubt in delete command?
@Ak07, actually oldtable[i] contains the address of the head of linked list having elements with same hash value so actually we are not just deleting the head of linked list ,we are deleting the entire linkedlist whose head is oldtable[i], when we call delete oldtable[i] , the destructor is envoked for the head of linked list and since we have already implemented our recursive destructor in Node class we get the head deleted after the other nodes in the linked list are deleted
here i have explained how destructor is working :- I didnot understand the explaination of destructor
In case of any doubt feel free to ask
Mark your doubt as RESOLVED if you got the answer
as you mentioned that oldtable[i] stores the address of the head of linked list that is that the oldtable[i] contains data type node * so when we do delete oldtable[i] shouldnt the pointer of type node which is storing the head of linked list be deleted rather than the head ans subsequently trhe whole linked list?
@Ak07, i think you have misunderstood how delete works, what deletes does is it takes the pointer of data to be deleted (by deleting we mean freeing up space) , so what happens is when you do delete oldtable[i] ; oldtable[i] is a pointer and has the address of the head of linked list , what delete does is not delete the pointer itself , it frees up the data in the address that pointer is storing.
do ask if you have any doubt in this, it is an important concept make yourself clear with it
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.