How insertinbst() function always return the main node though we traverse to the end of tree to attach new node

how insertinbst() function always return the main node though we traverse to the end to attach new node

@guptanikhil898
Because you access the tree using only the root node, this is the reason the root node is returned. What happens is that when you traverse the bst to insert the nodes, because you are performing the operations using pointers, you are able to insert the nodes. This is the advantage of using pointers. You can manipulate the memory using their addresses.

If my answer is able to answer your query, please mark the doubt as resolved.

but when we use root=root->left the root is now left element of main root and it keep on changing till we get null then new node is created and it address is returns then how now node is pointing to mian node show this by making tree please