Q:

What is the benefit of using double pointer in C/C++

I am new to C/ C++.
I was going through some of the coding questions related to trees and came across this double pointer notation. Can we do the same things using single pointer as first argument in the below function as we can do with double pointers.
void operate(struct Node *root, struct Node **head_ref){ //do something}

A:

There are two ways of interpreting a pointer; a reference to something, or an array. Considering this is a tree, this is probably the first: a reference to another pointer.
Every argument to a function in C is passed by value, which means that if you change the pointer inside the function, it won't be changed outside. To guarantee it is also changed outside, you can use a reference to the pointer: double pointers. You can consider the following example.
void function(int a) {
    a = 5;
}

Even if a is changed above, it is not changed outside of the function. But in this other case,
void function(int * a) {
    *a = 5;
}

the value a is changed outside the function as well. The same thought process can be applied to a pointer(which is also a value).

