`
#include
using namespace std;
class Node {
public:
int val;
Node* left;
Node* right;
// Constructor to initialize the node
Node(int value) {
val = value;
left = NULL;
right = NULL;
}
};
// Inorder traversal (Left, Root, Right)
void inorder(Node *root) {
if (root == NULL)
return;
inorder(root->left);
cout << root->val << " ";
inorder(root->right);
}
int main() {
// Creating nodes
Node* root = new Node(10);
Node* a = new Node(20);
Node* b = new Node(30);
Node* c = new Node(40);
// Constructing the tree
root->left = a;
root->right = b;
a->left = c;
// Performing inorder traversal
cout << "Inorder Traversal: ";
inorder(root);
cout << endl;
return 0;
}
`
`
`