Questions tagged [avl-tree]

Named after its inventors, Adelson-Velskii and Landis, an AVL tree is a self-balancing binary search tree.

Named after its inventors, Adelson-Velskii and Landis, an AVL tree is a self-balancing binary search tree. They were the first dynamically balanced trees to be proposed.

Like red-black trees, they are not perfectly balanced, but pairs of sub-trees differ in height by at most 1, maintaining an O(logn) search time.

923 questions
-2
votes
1 answer

Why does free function in my delete operation in my AVL tree not working as it is intended?

struct node { int data; struct node* left; struct node* right;}; int Getheight(struct node* root) { if(root==NULL) { return -1; } if(root->left==NULL && root->right==NULL) { return 0; } else…
-2
votes
4 answers

Store substring between double quotes in cpp

I am implementing the ALV tree, and I need to read input from the command line. An example of the command is as follows: insert “NAME_ANYTHING_IN_QUOTES_$” ID where NAME_ANYTHING_IN_QUOTES_$ is the data being stored in the AVL tree, and ID is used…
-2
votes
1 answer

Amortized Time Calculation in AVL tree

My professor showed the following problem in class and mentioned that the answer is O(1) while mine was quit different, I hope to get some help knowing of what mistakes did I made. Question: Calculate the Amortized Time Complexity for F method in…
user14826913
-2
votes
2 answers

Instantiated from here

I have a problem with "instantied from here". template class tree { public: tree(){root=0;} void addAVL( const E &data) throw(bad_alloc); private: class Node { public: E data; Noeud *…
Roots
  • 63
  • 6
-2
votes
1 answer

Invalid read even though object exists

I am trying to implement a self-balancing binary search tree. When I try to get the height of the right branch, it works until I reach this point. Then I get a segmentation fault error and valgrind says there was an invalid read of size 8. The odd…
Blake Morgan
  • 767
  • 1
  • 7
  • 25
-2
votes
1 answer

Implementing an AVL Tree using smart pointers Part 2

I made a similar post on here but I did not get any useful feedback. I thus tried to re-do my code a bit to see if that would lead to any decent results. So far my code compiles but yet does not print anything and I am not sure why. I have an…
user9366862
-2
votes
1 answer

AVL Trees:Maximimum and Minimum nodes if height is given?

What is the minimum and maximum number of nodes on an AVL tree of height 6?
dilk
  • 103
  • 3
  • 10
-2
votes
1 answer

Faster than O(log N) int set implementation in Java?

Fastutil has nice class IntAVLTreeSet which has #firstInt() and #lastInt() method, that I require. Unfortunately, AVL Tree is O(log N). Are there O(1) implementations of this? Is it possible at all? UPDATE I want O(1) lookups. Finding margins may…
Dims
  • 47,675
  • 117
  • 331
  • 600
-2
votes
1 answer

Print AVL Tree level by level (C++)

I am a beginner. I am trying to print an avl tree level by level and it should be from right to left. but the result from left to right. I hope you can solved my problem. Here is the piece of my source code: void printOrder( TreeNode *treePtr, int…
-2
votes
4 answers

how to get the height of avl tree in java

i tried this function private int height(AVLNode t ) { return t == null ? -1 : t.height; } i don't know what that method do can anyone explain it ?
user3766910
  • 45
  • 1
  • 8
-2
votes
1 answer

Implement from function for AVL Tree java

Question: My code below (doesn't work): public K from(K k, int i) throws NotFound { //reset stack parentNode = new Stack>(); //Returns node with value k Node foundNode = findNode(k, root); return…
user2635911
  • 472
  • 2
  • 6
  • 16
-2
votes
1 answer

Storing an Author class in an AVL tree

I'm creating a software product which is an AVLTree containing the details of Authors. The Author class contains: Name, Year Of Publish and List of Books (using LinkedList<> collection). The Author objects will be stored in the AVLTree with the Name…
user1978596
-3
votes
2 answers

AVL tree, Is the following claim true? BIG O

I saw the following claim: Let T be an AVL tree and TL be the number of nodes in the left sub tree of the root while TR is the number of nodes in the right sub tree of the root. Then: TL = Big Theta (TR) which both means: TL = O(TR) and TL = Big…
user14826913
-3
votes
1 answer

Iterator implement on AVL tree java

I'm trying to implement iterator on AVL tree, I'm stuck at this specific function: /** * @return an iterator for the Avl Tree. The returned iterator iterates over the tree nodes. * in an ascending order, and does NOT implement the…
Error 404
  • 427
  • 5
  • 25
-3
votes
1 answer

Member function returns the previous value of a variable

I am constructing an AVL tree program. I got stuck in a rather easy situation, but difficult to understand what is wrong. The reason I think it is the program's fault and not mine is because I have the exact same class function right before it with…
1 2 3
61
62