void inorder_walk(struct t_node *root, print pr) { if(root) { inorder_walk(root->left, pr); pr(root->data); inorder_walk(root->right, pr); } }
int main(void) { /* int inorders[] = {4, 7, 2, 1, 5, 3, 8, 6}; int preorders[] = {1, 2, 4, 7, 3, 5, 6, 8}; struct TreeNode* root = rebuilt_tree(preorders, 0, 7, inorders, 0, 7); preorder_walk(root); printf("\n"); inorder_walk(root); printf("\n"); */ int inorders_tree1[] = {9, 8, 4, 2, 7, 18, 17}; int preorders_tree1[] = {18, 8, 9, 2, 4, 7, 17}; struct TreeNode* tree1 = rebuilt_tree(preorders_tree1, 0, 6, inorders_tree1, 0, 6); preorder_walk(tree1); printf("\n"); inorder_walk(tree1); printf("\n"); int inorders_tree2[] = {9, 8, 2}; int preorders_tree2[] = {8, 9, 2}; struct TreeNode* tree2 = rebuilt_tree(preorders_tree2, 0, 2, inorders_tree2, 0, 2); preorder_walk(tree2); printf("\n"); inorder_walk(tree2); printf("\n"); printf("Contain: %d\n", contain_substructure(tree1, tree2)); }
void inorder_walk(avl_node *root) { if(root == NULL) return; inorder_walk(root->left); printf("key: %d ", root->key); inorder_walk(root->right); }
static void inorder_walk(T tree, const Node * node, void (*fun) (Item)) { if (node != NIL(tree)) { inorder_walk(tree, node->left, fun); if (fun != NULL) fun(node->item); inorder_walk(tree, node->right, fun); } }
void inorder_walk(BSTree &t) { if(t==NULL) return; inorder_walk(t->lchild); printf("%s %.4f\n",t->tree_name,t->time*100.0/count); inorder_walk(t->rchild); }
void inorder_walk(struct TreeNode* root) { if (root == NULL) { return; } if (root->left != NULL) { inorder_walk(root->left); } printf("%d ", root->value); if (root->right != NULL) { inorder_walk(root->right); } }
void tree_walk(const T tree, void (*fun) (Item)) { assert(tree != NULL); assert(fun != NULL); inorder_walk(tree, tree->root, fun); }
int main() { char name[100]; BSTree t=NULL; count=0; while(gets(name)) { tree_insert(t,name); count++; } inorder_walk(t); return 1; }
void walk(const Func &func) { inorder_walk(func); }
void inorder(struct bs_tree *tree, print pr) { inorder_walk(tree->root, pr); printf("\n"); }