C ++ program for the above approach
#include <bits/stdc++.h> NEW_LINE using namespace std ; struct Node { int val ; Node * left , * right ; } ; struct Node * newNode ( int data ) { struct Node * temp = ( struct Node * ) malloc ( sizeof ( struct Node ) ) ; temp -> val = data ; temp -> left = NULL ; temp -> right = NULL ; return temp ; }