示例#1
0
void bst_print(bst_tree_t *tree)
{
    if (tree == NULL) {
        return;
    }

    bst_print(tree->left);
    printf("%d ", tree->elem);
    bst_print(tree->right);
}
示例#2
0
void bst_print(node_t* node){
	if (ISNULL(node)) {
		return;
	}
	fprintf(stderr, "key: %lu ", node->key);
	fprintf(stderr, "address %p ", node);
	fprintf(stderr, "left: %p; right: %p \n", node->left, node->right);
	
	bst_print(node->left);
	bst_print(node->right);
}
示例#3
0
文件: bst.c 项目: serge-v/common
void
bst_print(struct bnode* x, int level)
{
	if (x == NULL)
		return;

	bst_print(x->left, level + 1);
	bst_print(x->right, level + 1);

	printf("%d ", x->v);
}
示例#4
0
int main(void) {
    bst_tree_t *tree = NULL;
    tree = bst_insert(1, tree);
    tree = bst_insert(8, tree);
    tree = bst_insert(2, tree);
    tree = bst_insert(4, tree);
    tree = bst_insert(10, tree);
    tree = bst_insert(7, tree);
    bst_print(tree);
    printf("\n");
    tree = bst_delete(8, tree);
    bst_print(tree);
    printf("\n");
    bst_make_empty(tree);
}
int main(void) {
    avl_tree *tree;
    avl_node *cur;
    tree = avl_create(int_cmp);

    int nums[] = {58, 98, 43, 74, 74, 65, 93, 81, 76, 6, 78, 73, 62, 84, 48, 21, 15, 41, 36, 98};
    // int nums[] = {1,2,3,4,5,6,7};

    for(int i = 0; i < 20; i++) {
        avl_insert(tree, &nums[i]);
    }

    for(int i = 0; i < 5; i++) {
        // bst_print((bst*)tree, tree_print);

        // printf("\nremoving: %d\n\n", nums[i]);
        avl_delete(tree, &nums[i]);

        // bst_print((bst*)tree, tree_print);
        // printf("\n===========================\n\n");
    }

    bst_print((bst*)tree, tree_print);

    return 0;
}
void hash_table_print(hash_table_bst_t* t) {
	bst_print(t->impl);
}