typedef struct nodetype
{
int data;
struct nodetype * left;
struct nodetype * right;
}node;
typedef node * tree;
tree newNode(int data)
{
tree temp;
temp = NULL;
temp = (tree)malloc(sizeof(nodetype));
temp->data = data;
temp->right = NULL;
temp->left = NULL;
return temp;
}
Here in the function newNode, to create a node we assign NULL value to the "temp". I dont understand whether this is necessary. What will be the implications if we dont initialize it with NULL and in which cases should I take care of assigning a ptr to NULL while initializing it ??
tree temp = NULL;.