文档详情

假设二叉树中结点值互不相同,输入一给定值,查找给定值对应的结点是否存在(Suppose that the values of the nodes in the two fork tree are different from each other, and enter a given value to find the node corresponding to the given value).doc

发布:2017-07-19约4.86千字共13页下载文档
文本预览下载声明
假设二叉树中结点值互不相同,输入一给定值,查找给定值对应的结点是否存在(Suppose that the values of the nodes in the two fork tree are different from each other, and enter a given value to find the node corresponding to the given value) Training four: the use of two binary tree traversal, the expression of the value of the expression Practice 4.1, two fork tree operation: Training purpose requirements: 1. understand how to build two fork trees. 2. master the method of finding nodes in two fork tree. Training content: The value of nodes in a two fork tree is different from each other, that is, each value is unique. Enter a given value, determine whether the corresponding value of the node exists in the two fork tree. Application of 4.2 training trees Training purpose requirements: 1., master tree can deal with the relationship between layers. 2. using expressions two fork tree, you can easily solve the problem of expression conversion. 3. learn to use the two fork tree to traverse the value of the calculated expression. Training content: The 5*6+4*3 expression two fork tree into the array, and then use recursive method to create expressions two fork tree, output expression two fork tree three traversal results, and calculate the expression value. Training reference program: Training 4.1 reference procedures: Typedef struct node1 {char data; Struct, node1, *lchild, *rchild; }BT; #include stdio.h #include stdlib.h BT * createbt () {BT *q; BT *s[30]; Int, J, I, x; Printf (creat bintree\n\n); Printf (I, x =); Scanf (%d, %c, i, x); While (I! = 0 X! = $) {q = (BT*) malloc (sizeof (BT)); / * create a new node q*/ Q-data = x; q-lchild = NULL; q-rchild = NULL; S[i] = q; /*q new node address in the s pointer array. If (I! = 1) /*i = 1, corresponding to the node is the root node. {j = I / 2; / * number j*/ for the parent node If (I% 2 = = 0) s[j]-lchild = q; /*q node number is even hung on the left side of J * / parent node Else s[j]-rchild = q;} /*q node number is odd is hanging in the parent node j on the
显示全部
相似文档