Tree Search Height Method (BST): for both the left subtree and the right subtree ::
Put the elements you want to put in your binary tree into an array before creating the actual tree. Calculate the number of elements that are larger than the root, which will go to the left of the tree and similarly to the right side.
Then add the elements to the tree. Each time, set the flag bit to 1 or 0 depending on whether you add it to the left subtree or to the right.
if(root->right && flagleft==1) no_left--; else if(root->right && flagright==1) no_right--;
This is when adding node to the left side.
if(root->left && flagl==1) nl--; else if(root->left && flagr==1) nr--;
This is until you add node to the right side.
source share