Exemplo n.º 1
0
/* post-order traversal */
static int avl_postorder(avl_node_t* root, avl_key_t array[], int index)
{
    if (root != NULL)
    {
        index = avl_postorder(root->left, array, index);
        array[index++] = root->key;
        index = avl_postorder(root->right, array, index);
    }
    return index;
}
Exemplo n.º 2
0
void avl_postorder(avl_node * root, void (*call_back)(avl_node * n, void * d), void * user_data)
{
	if (root != NULL)
	{
		avl_postorder(root->left, call_back, user_data);
		avl_postorder(root->right, call_back, user_data);
		call_back(root, user_data);
	}

	return;
}
Exemplo n.º 3
0
/* print nodes to array */
int avl_serialize(avl_tree_t* tree, avl_key_t array[], size_t len)
{
    assert(tree && array);
    if (tree->size > len)
    {
        return 0;
    }
    return avl_postorder(tree->root, array, 0);
}