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. void leftBoundary(BinaryTreeNode<int>* root){
  17. if(root == NULL){
  18. return;
  19. }
  20. if(root->left){
  21. cout<<root->data<<" ";
  22. leftBoundary(root->left);
  23. }
  24. else if(root->right){
  25. leftBoundary(root->right);
  26. cout<<root->data<<" ";
  27. }
  28.  
  29. }
  30. void rightBoundary(BinaryTreeNode<int>* root){
  31. if(root == NULL){
  32. return;
  33. }
  34. if(root->right){
  35. rightBoundary(root->right);
  36. cout<<root->data<<" ";
  37. }
  38. else if(root->left){
  39. rightBoundary(root->left);
  40. cout<<root->data<<" ";
  41. }
  42.  
  43. }
  44.  
  45. void solve(BinaryTreeNode<int>* root){
  46. /* Don't write main().
  47. * Don't read input, it is passed as function argument.
  48. */
  49. if(root == NULL){
  50. return;
  51. }
  52. if(root->left == NULL || root->right == NULL){
  53. cout<<root->data<<" ";
  54. }
  55. cout<<root->data<<" ";
  56. leftBoundary(root->left);
  57. rightBoundary(root->left);
  58. }
  59.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:16:19: error: variable or field ‘leftBoundary’ declared void
 void leftBoundary(BinaryTreeNode<int>* root){
                   ^~~~~~~~~~~~~~
prog.cpp:16:19: error: ‘BinaryTreeNode’ was not declared in this scope
prog.cpp:16:34: error: expected primary-expression before ‘int’
 void leftBoundary(BinaryTreeNode<int>* root){
                                  ^~~
prog.cpp:30:20: error: variable or field ‘rightBoundary’ declared void
 void rightBoundary(BinaryTreeNode<int>* root){
                    ^~~~~~~~~~~~~~
prog.cpp:30:20: error: ‘BinaryTreeNode’ was not declared in this scope
prog.cpp:30:35: error: expected primary-expression before ‘int’
 void rightBoundary(BinaryTreeNode<int>* root){
                                   ^~~
prog.cpp:45:12: error: variable or field ‘solve’ declared void
 void solve(BinaryTreeNode<int>* root){
            ^~~~~~~~~~~~~~
prog.cpp:45:12: error: ‘BinaryTreeNode’ was not declared in this scope
prog.cpp:45:27: error: expected primary-expression before ‘int’
 void solve(BinaryTreeNode<int>* root){
                           ^~~
stdout
Standard output is empty