如何使用 libavl?

Mad*_*han 5 c sorting gnu binary-search-tree

我正在尝试将 GNU libavl( http://adtinfo.org/ ) 用于我的一个学术项目。我需要一个足够简单的教程,介绍如何使用库提供的 BST(二叉搜索树)实现。我需要做的是根据值使用 BST 对(键,值)对(大约 30000 个字符串和频率)进行排序。尽管该库文档齐全,但它并没有直接回答我的问题,而且我没有时间通读所有文档和测试代码。我想知道是否有更快的方法来进行排序。

Aru*_*run 2

int main(int argc, char **argv)
{
    tree *avl_tree = NULL;
    struct data tmp;
    unsigned result;

    (void) argc;
    (void) argv;

    // Initialize a new tree with our three previously defined
    // functions to store data structure.
    avl_tree = init_dictionnary(data_cmp, data_print, data_delete, data_copy);

    tmp.key = 42;
    tmp.value = 4242;

    // Add element {42, 4242} in our tree.
    result = insert_elmt(avl_tree, &tmp, sizeof(struct data));
Run Code Online (Sandbox Code Playgroud)

  • @Madushan 你看过这个例子吗?它不仅只包含一个示例(仅使用 AVL 树,而不是 GNU libavl 提供的任何其他类型的二叉树),而且我什至不知道这个 github 项目与 GNU 项目有何关系! (2认同)