How can I print my binary tree in this way?
the original tree I need
5 5
/ \
2 9 2 9
/ \ / \
0 3 7 12 0 3 7 12
My print function is :
void display(struct node* start){
cout << start->data << " ";
if(start != NULL){
if(start->left){
cout << "\n";
display(start->left);
}
if(start->right) {
display(start->right);
}
}
}
Currently my function prints this way
5
2
0 3 9
7 12