fork download
  1. // Following is the Binary Tree node structure
  2. /**************
  3. class BinaryTreeNode {
  4.   public :
  5.   T data;
  6.   BinaryTreeNode<T> *left;
  7.   BinaryTreeNode<T> *right;
  8.  
  9.   BinaryTreeNode(T data) {
  10.   this -> data = data;
  11.   left = NULL;
  12.   right = NULL;
  13.   }
  14. };
  15. ***************/
  16. int sum = 0;
  17. int leftSum(BinaryTreeNode<int>* root){
  18. // Write your code here
  19.  
  20. if(root == NULL){
  21. return 0;
  22. }
  23. if(root->left == NULL){
  24. sum+=root->left->data;
  25. }
  26. sum+=leftSum(root->left);
  27. sum+=leftSum(root->right);
  28. return sum;
  29. }
  30.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:17:13: error: ‘BinaryTreeNode’ was not declared in this scope
 int leftSum(BinaryTreeNode<int>* root){
             ^~~~~~~~~~~~~~
prog.cpp:17:28: error: expected primary-expression before ‘int’
 int leftSum(BinaryTreeNode<int>* root){
                            ^~~
stdout
Standard output is empty