我该如何以这种方式打印我的二叉树?
the original tree I need
5 5
/ \
2 9 2 9
/ \ / \
0 3 7 12 0 3 7 12
我的打印函数是:
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);
}
}
}
目前我的函数是这样打印的
5
2
0 3 9
7 12