Dynamic establishment of binary tree in data structure

CSDN Q & A 2022-02-13 07:02:40 阅读数:149

dynamic establishment binary tree data
// Preordered spanning tree void create_tree(RTreeNode *p){ char ch; scanf("%c", &ch); if(ch == '#') { p = NULL; // Input # = NULL, Can't type... On the keyboard NULL Single character  return ; } else { p = init_node(); p->data = ch; if(p == NULL) { exit(0); } printf(" Please enter the current node %c The left child , If there is no left child , Please enter #\n", ch); create_tree(p->left_child); printf(" Please enter the current node %c The right child , Without the right child , Please enter #\n", ch); create_tree(p->right_child); }}



Take the answer :

use new Just create a new linked list .


copyright:author[CSDN Q & A],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130702390829.html