3. What will be the output of the following C code that inserts values into a BST and then performs an inorder traversal?
typedef struct Node {
int data;
struct Node* left;
struct Node* right;
} Node;
Node* insert(Node* root, int val) {
if (root == NULL) {
Node* newNode = (Node*)malloc(sizeof(Node));
newNode->data = val;
newNode->left = newNode->right = NULL;
return newNode;
}
if (val < root->data) root->left = insert(root->left, val);
else root->right = insert(root->right, val);
return root;
}
void inorder(Node* root) {
if (root == NULL) return;
inorder(root->left);
printf("%d ", root->data);
inorder(root->right);
}
int main() {
Node* root = NULL;
root = insert(root, 10);
root = insert(root, 5);
root = insert(root, 15);
inorder(root);
return 0;
}