many times it is felt to pass head pointers as parameter to functions...
v simple solution is to pass by reference..
this way u dnt have to change internal syntaxes in side your insert functions and all other functions where modification in the data structure is required.
void insert ( struct T * & node, int data)
{
if (!node)
{ node = (struct T * )malloc(sizeof(struct T));
node->data = data;
node->left = node->right = NULL;
}
}
v simple solution is to pass by reference..
this way u dnt have to change internal syntaxes in side your insert functions and all other functions where modification in the data structure is required.
void insert ( struct T * & node, int data)
{
if (!node)
{ node = (struct T * )malloc(sizeof(struct T));
node->data = data;
node->left = node->right = NULL;
}
}