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
-1
votes
3 answers

Getting stack overflow when trying to implement a rotation for AVL Tree

Everytime I add a new node into the tree first it sorts it as a binary tree then recursively look up for violations in AVL. The problem is in my rotate function I tried to test for the AVL violation which requires a left-left rotation and when I do…
mouse_s
  • 58
  • 1
  • 9
-1
votes
1 answer

How to search, insert, remove nodes in AVL trees when the key is a string

I have a program that reads in strings from a text file and then stores them in an AVL tree, I also have to remove nodes and insert new ones from the command line. I understand how to do this when the nodes have ints as keys, but mine are…
Santi GS
  • 87
  • 1
  • 3
  • 9
-1
votes
1 answer

AVL tree, c, rotation implementation

code here: http://pastebin.com/VAdc67bE There's a problem in function rotacao_esquerda. This is a rotation of a AVL tree. How to fix it?
diogo
  • 7
  • 1
  • 2
-1
votes
1 answer

RedBlack and AVL tree c++

I want to understand implementation of red black and AVL trees using C++. I checked some websites about them but most of them are complex and difficult to understand. Could you suggest me some resources please?
Tuğcan Demir
  • 113
  • 3
  • 11
-1
votes
1 answer

inserting in AVL BST

I am learning about AVL trees, this makes scense to me, but i can't get it to work properly. #include #include #include #define LEFT -1 #define BAL 0 #define RIGHT 1 typedef int Key; typedef void * Info; struct…
skills
  • 315
  • 5
  • 17
-1
votes
1 answer

AVL tree(c++), program keeps on crashing

I am working on an exercise in processing an AVL tree. The debugger shows no errors. I ran the program and it is supposed to output an output text file. However the program crashes every time. #include #include #include…
soulless
  • 383
  • 1
  • 5
  • 18
-1
votes
1 answer

AVL Tree find Closest Key

Find a String: X, which may or may not exist in the AVL tree. Can i have the pseudo code to get X if it exists OR find the next biggest string after X? I have done the code for successor. Successor finds the next biggest node. protected BSTVertex…
RStyle
  • 875
  • 2
  • 10
  • 29
-1
votes
1 answer

Implement REMOVE method for AVL Tree

I have imlemented so far http://pastebin.com/gXJVXdLS 5. Create a remove method. search the tree if the item is found, then you kill it. you have to then balance the tree in AVL fashion to properly fill the hole that you make. Again, use the…
VeteranLK
  • 717
  • 7
  • 17
-1
votes
1 answer

Class for AVL trees (C++)

So I wanted to make an AVL tree in C++. I used a class to make the nodes and a class for the rest of the fuctions (instert, delete etc). When I want to make more than one tree I decided that I needed to make more roots (one for every tree). The…
Jenny
  • 45
  • 8
-1
votes
1 answer

Null pointer Exception in java while finding no of values in given range in val tree

I am trying to print no of node values in a given range in an avl tree .But when I try to run the program I get NullPointerException. I couldn't get much help from previous questions of same topic.How can i correct it here.Here's my code of that…
user2944059
  • 23
  • 1
  • 5
-1
votes
1 answer

Random string and number generating same value repeatedly in C

I am trying to implement the AVL tree in C. I am storing a random integer and a random string at each node. I changed my code and getting random strings. But now I have another problem now. During in-order traversal I am getting same strings as…
user2784016
  • 179
  • 1
  • 7
-1
votes
1 answer

C: Creating a AVL balanced Tree

I'm trying to write a code to create a AVL balanced binary tree. The purpose is that the subtree shall be rotate to keep the (AVL) balance each time a new node is inserted. (All values in the left subtree of a node must be smaller than this node…
Kaiser
  • 35
  • 1
  • 3
  • 9
-1
votes
1 answer

AVL Tree rotation. Different possibilities

I have a question regarding the insertion in an AVL Tree. I noticed that there are some cases in which for example, after you inserted an element, both the parent and it's child are breaking the AVL condition. For example here…
gliga bogdan
  • 143
  • 1
  • 5
-1
votes
1 answer

AVLTree heigth always came back zero

Hi I have this AVLTree but I just cannot make the height method working. It always gives zero. Can some of you take a look on it and maybe find out what am I missing. As you can see I tried different solutions but I have got no idea. It would be a…
-1
votes
1 answer

How to create a balanced Tree from a list of elements using this AVL predicate in Prolog?

I am studying Prolog and I find it difficult to implement a predicate that takes a list and builds a balanced tree from it. I have implemented these predicates that build an AVL Tree (I have taken it from Bratko book and it works fine): %%% A…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596