create a binary tree
Node * root = newNode ( 20 ) ; root -> left = newNode ( 10 ) ; root -> right = newNode ( 30 ) ; root -> left -> left = newNode ( 5 ) ; root -> left -> right = newNode ( 15 ) ; root -> left -> right -> left = newNode ( 12 ) ; root -> right -> left = newNode ( 25 ) ; root -> right -> right = newNode ( 40 ) ; cout << " data ▁ at ▁ level ▁ 1 ▁ : ▁ " ; int ret = printKDistant ( root , 1 ) ; if ( ret == false ) cout << " Number ▁ exceeds ▁ total ▁ number ▁ of ▁ levels STRNEWLINE " ; cout << " data ▁ at ▁ level ▁ 2 ▁ : ▁ " ; ret = printKDistant ( root , 2 ) ; if ( ret == false ) cout << " Number ▁ exceeds ▁ total ▁ number ▁ of ▁ levels STRNEWLINE " ; cout << " data ▁ at ▁ level ▁ 3 ▁ : ▁ " ; ret = printKDistant ( root , 3 ) ; if ( ret == false ) cout << " Number ▁ exceeds ▁ total ▁ number ▁ of ▁ levels STRNEWLINE " ; cout << " data ▁ at ▁ level ▁ 6 ▁ : ▁ " ; ret = printKDistant ( root , 6 ) ; if ( ret == false ) cout << " Number ▁ exceeds ▁ total ▁ number ▁ of ▁ levels STRNEWLINE " ; return 0 ; }