I am struggling to print a binary search tree like the below output (in-order traversal):
2, 3, 6, 9
the output I get:
2, 3, 6, 9,
The code I have:
void inorder(struct node* root)
{
if (root != NULL) {
inorder(root->left_node);
printf("%d, ", root->value);
inorder(root->right_node);
}
}
how struct node is implemented:
struct node {
int value;
struct node *left_node;
struct node *right_node;
};
I am not sure how to get rid of the comma and the space characters after the last element.