Using a double pointer instead of a single pointer

I am working on a binary search tree.

So here is the structure used to represent node:

typedef struct TreeNode
{
int num;
struct TreeNode *left,*right;
}TREENODE;

To insert a node into a tree, I have the following signatire method

void InsertNode(TREENODE **root,int data);

In the above method, why do we need a double pointer. We can use one pointer!

Do we use double pointer to avoid duplication?

+5
source share
5 answers

No, this is necessary in case of rebalancing. After changing the balance, you can change the root.

, . . , ? TREENODE. , , . , node . , root. , , , . AVL.

+7

, , .

+2

- , .

+2

, . - , node, .

0

" " , <some_class>* . , . , . char* ( ) char** ( )

: ? ?

0

All Articles