コード例 #1
0
ファイル: bst.c プロジェクト: hegek87/Data-Structures
void inorder_walk(struct t_node *root, print pr) {
    if(root) {
        inorder_walk(root->left, pr);
        pr(root->data);
        inorder_walk(root->right, pr);
    }
}
コード例 #2
0
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));
}
コード例 #3
0
ファイル: avl.c プロジェクト: meteorgan/algorithm
void inorder_walk(avl_node *root)
{
	if(root == NULL)
		return;
	inorder_walk(root->left);
	printf("key: %d ", root->key);
	inorder_walk(root->right);
}
コード例 #4
0
ファイル: RBtree.c プロジェクト: spockwangs/snippets
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);
    }
}
コード例 #5
0
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);
    
}
コード例 #6
0
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);
    }
}
コード例 #7
0
ファイル: RBtree.c プロジェクト: spockwangs/snippets
void tree_walk(const T tree, void (*fun) (Item))
{
    assert(tree != NULL);
    assert(fun != NULL);

    inorder_walk(tree, tree->root, fun);
}
コード例 #8
0
int main()
{
    char name[100];
    BSTree t=NULL;
    count=0;
    while(gets(name))
    {

        tree_insert(t,name);
        count++;
    }
    inorder_walk(t);
    return 1;
}
コード例 #9
0
ファイル: binary_tree.hpp プロジェクト: glynos/fundamentals
 void walk(const Func &func) {
     inorder_walk(func);
 }
コード例 #10
0
ファイル: bst.c プロジェクト: hegek87/Data-Structures
void inorder(struct bs_tree *tree, print pr) {
    inorder_walk(tree->root, pr);
    printf("\n");
}