avl-tree

    0热度

    1回答

    考虑下面的算法,通过使用二叉搜索树排序n个元素的列表,该算法的时间复杂度: initialise t to be an empty binary search tree for each element x in the list, add x to t while t is not empty, remove and print the smallest element

    1热度

    1回答

    我从学了AVL树C数据结构和算法分析,我自己键入代码,其插入函数不能正常工作。 我用很多数据检查过这些函数。有些节点不能插入,有些节点是随机插入的。未分类,我的意思是。 这里是我的代码部分: AVLTree.h: /* Data structures model */ typedef int data_type; typedef struct avlnode { data_type

    0热度

    1回答

    #include<stdio.h> #include<stdlib.h> // An AVL tree node struct node { int key; struct node *left; struct node *right; int height; }; // A utility function to get maximum o

    1热度

    1回答

    嘿,我必须找到最有效的方法来打印一个数字通过给位置。输入是这样的: 8 (N-> N Numbers) INS 100 (Add 100 to the tree) INS 200 (Add 200 to the tree) INS 300 (Add 300 to the tree) REM 200 (Remove the number 200 from the tree) PER 1 (

    1热度

    1回答

    我明天考试,有3个问题在笔记上我无法理解。 1- #searches >> #insertions和#deletions = 0哪棵树? (Avl或红黑树)(答案是Avl) 2-#插入> 0和#搜索=#删除= 0哪棵树? (Avl或红黑树)(答案是红黑) 3-#插入=#删除和#搜索= 0哪棵树? (Avl或红黑树)(答案是红黑) 你能解释一下吗? 感谢您的帮助

    -4热度

    1回答

    你好,我有一个问题。如何在每个节点上放置它下面的叶子数量?以及如何有效地更新它(插入和删除过程中)。我无法弄清楚。 Ty求助。这里是相关的代码: #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> using namespace std; struct AVLNode {

    0热度

    1回答

    我正在使用字符串作为键的avl树上工作。打印语句指示插入正在发生,但在测试功能中,它报告根的左右节点保留为空。 这里是我的AVL树代码: #include "AVLAdt.h" void printVal(node * toPrint){ printf("\n node value: %s\n", toPrint->nodeValue); } node * search(nod

    0热度

    1回答

    我一直在尝试在我的AVL程序中实现旋转函数,并且在调用右旋转函数时继续出现seg错误。我进行了测试Valgrind的,并有3个错误,我得到: ==23399== 1 errors in context 1 of 3: ==23399== Invalid read of size 4 ==23399== at 0x8048C3A: insert (avltree.c:190) ==23399=

    1热度

    5回答

    所以这里的情况: 我有数百万,可能是数十亿字符串,我试图解析并放入一个排序结构,可以说我有5,000,000字符串。 我想写一个快速的程序,可以把所有这些字符串从一个未排序的向量转换成一个有序的数据结构,也可以快速搜索结构,因此AVL树的推理(最终我打算使用散列更快的查找的az表,但后来才发现)。我首先将所有的字符串都放到一个向量中,但它们都是混乱的,没有排序的,长度也不一样。 我不想在我的树中有

    0热度

    1回答

    我执行的AVL树写道,功能,将计算给定树的平衡因子: int avlTree::balanceFactor(avlNode *tree){ return height(tree->left) - height(tree->right); } 但似乎确实同时返回我的正确的平衡因素树,它不会让我确定树是AVL平衡的天气,因为根据定义,对于每个子树都应该检查平衡因子。即该树: 会的,根据