Is there a difference bwtween node<T>**x and node **x

If yes ,than how.Also explain if in this question we will declare it as node **table than what will be the outcome

Also explain why again we are declaring template.we are declaring it twice.Will it not create confusion for compiler

~node(){ if(next!=NULL) delete nex} …This is the destructor defined in above question.How will it delete all the subsequent nodes.It will delete only one node and the nodes which are attached to this ode will lead to memory leak.Explain

Hey
Regarding node** x
It is just the way you do when you are making a templated linked list. It means that the linked list can support any data type.

Regarding the destructor:-
first thing you need to know is that the destructor of a class object is invoked when the class object goes out of scope or is deleted using delete (if dynamically allocated )
let’s see the code :-

~Node(){
    if(next!=NULL){
        delete next;
    }
}

here this is an example of recursive destructor
so if we have linked list as 1->2 ->3 ->4 ->5 -> NULL
and when we delete 1 then destructor is invoked for 1 and it checks for its next which is present and is the address for 2 thus invoking destructor of 2 similarly we reach 5 and check for its next which is NULL thus is returned to 4 and 5 is deleted and we return to 3 and 4 is deleted and finally we will be left with 1.
try to dry run it yourself

Also explain why again we are declaring template.we are declaring it twice.Will it not create confusion for compiler???Please also explain this one

Hello @KetanPandey you have raise the doubt again please elaborate what problem you are facing because another TA has already responded you in the best way possible.

Sir , i want to know that we are node->next is holding an address similar to what table[i] will be holding in hashtable,but in hashtable the datatype is node** but in node the data type is just node** but they are storing the same address. Please explain this.Thank you

@KetanPandey 1. node* means pointer to a node object. You need node* pointer to iterate over linked list
2. node** means a double pointer to a single pointer who points to a node object. You need node** pointer to make the head of a linked list at caller scope to point to something else (like a new node when you add a node ahead in the linked list or to point to NULL when you delete the only element present in the linked list)

Note ** means that it is pointer to a pointer so basically when you are doing node* it is pointing to the node present at the next.
but node** means that there is lineked list at the next.
it keeps the address of the next linked list.
Happy Learning!!

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.