avl-tree

setting parent on AVL tree

I am trying to implement an AVL tree and not sure about the best way to do insert and track each node's parent. This is educational so please do not suggest "use boost" :) This compiles but I am not convinced of its correctness or that it is the best way. Specifically this insert(someNumber,root,root); Also, I will redo the height p...

Doing rotation for AVL

I am trying to implement an AVL tree for educational purposes but the rotation is not working like I expected. I have nodes which each have a pointer to a left, right and parent node. Below is my code for the right-right rotation. First the imput (Just so I make it clear, this is what I understand to be the RR case) a \ b \ ...

Performance of an AVL Tree in C#

I have implemented an AVL tree in C# whose insertion matrix is as follows Number of Elements Time taken to insert (sec) ------------------------------------------------------ 10 0.067 100 0.073 200 0.112 500 0.388 900 ...

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? ...

"Rotating" to get AVL Tree

Why is the process of balancing to get an AVL tree called rotation? (While you are at it, what's single & double rotation?) Every textbook of mine blatantly uses that word without any explanation. ...

Recalculation of Balance Factor in AVL Tree

After performing a rotation to balance an AVL tree, immediately after an insertion, how can I change the balance factor of all the parent nodes (appropriately, by -1 or 1)? Each node of the AVL tree has the following structure: typedef struct _avlTree { nutbolt part; int balanceFactor; struct _avlTree *left,*right; } *avlTree; I h...

AVL Tree insertion

How do I calculate the balance factor for a particular node, when I am recursively calling an insert function for adding a node to an AVL tree. I haven't started on the rotation logic. I simply want to calculate the balance factors. In my current attempt, I am forced to store heights of left & right subtrees as I can't find the balance...

What is wrong with this AVL balancing code?

Everytime I use this my avlRotate function, it drops some elements from the tree. z is the node in which imbalance was detected, y is its subtree node having the greater height, x is the newly inserted node. This function is called immediately after a single insertion. #define RESTRUCTURE a->left = t0; a->right = t1; c->left = t2; c->...

What Tree structure should I use for indexing?

I'm thinking of experimenting with using a tree-structure for indexing as I want to test whether it is faster than my current indexing implementation which is in essence a hash based lookup. I've read up on various questions and articles about performance of B-Trees, AVL-Trees and Red-Black Trees and can't really see much difference bet...

How to check if my AVL tree implementation is correct?

Hello, guys. I think I've created an AVL tree implementation, but as AVL Tree is quite a complex structure, I need to test it. So the question is - how can I test it? Have you got any ideas? Up to this moment I have the following tests: basic sanity check - checks that for every node height equals max. height of child nodes + 1...