I am getting "cannot convert node** to node** error" for the given code. Here both are node**. Error is getting while the function insertintoBST is compared to its declaration. node is a structure variable. Here, I have tried to implement insertion into a binary search tree.
#include<stdio.h>
#include<conio.h>
void inserttoBST(struct node**,int,int);
void main()
{
int choice,i,j;
struct node{
int value;
int key;
struct node*left;
struct node*right;
};
struct node*root=NULL;
do{
printf("\n1.insert\n2.delete\n3.view list\n4.search");
scanf("%d",&choice);
switch(choice)
{
case 1: printf("\nEnter the key and data :");
scanf("%d%d",&i,&j);
inserttoBST(&root,i,j);
break;
case 2: break;
case 3:break;
case 4:break;
default:printf("\nInvalid Entry");
}
}while(choice!=10);
}
void inserttoBST(struct node**root,int keys,int val)
{
if(*root==NULL)
{
struct node*nodes=(struct node*)malloc(sizeof(struct node));
nodes->key=key;
nodes->val=val;
nodes->left=nodes->right=NULL;
*root=nodes;
}
else if((*root)->key<keys)
inserttoBST((*root)->right,int keys,int val);
else inserttoBST((*root)->left,int keys,int val);
}