I could not use the Insert_node to insert a node with corresponding key, and I couldn't figure out the problem. Keys is an array of integers I created earlier. Here is the code:
Node* Create_node(int x)
{
Node* newNode = (Node*)malloc(sizeof(Node));
newNode->key = x;
newNode->left = NULL;
newNode->right = NULL;
return newNode;
}
Node* Insert_node(Node** proot, int x)
{
Node* root = *proot;
if(root == NULL)
{
root = Create_node(x);
}
return root;
}
int main()
{
Node* root = Create_node(keys[0]);
Insert_node(&root->left,keys[1]);
printTree(root);
return 0;
}