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
-4
votes
1 answer

C++ Return does not work

Adding an element to the AVL tree. Tree currently has no elements. I am trying to add one. Function add performs ok, except program freezes and ends in 2 secs when it comes to return new node(k). Why is that? struct node { int key; unsigned…
-4
votes
1 answer

AVL tree, access pointer in struct

#define LEFT 1 #define BAL 0 #define RIGHT -1 typedef struct avl { int value; int bal; struct avl *left, *right; } *AVL; AVL lower (AVL a){ while ((a.left != NULL) || (a.right != NULL)) { if (a.bal = LEFT){ …
Dost
  • 33
  • 7
-4
votes
1 answer

Holding number of leaves under node in AVL tree

Hello I've got a question. How to hold in every node, number of leaves under it? And how to efficiently update it(during inserting and removing). I can't figure it out. Ty for help. Here is the relevant code: #include #include…
-4
votes
1 answer

C#: How to parse the AVL data packets coming from the Device FM4100 get the output as hexadecimal value

Is my parsing method worng? I got like this avl data format: 08010013ba7695698059a9f580eb76a140280048b045021f0101c70005e Codec ID :08 Count:01 strTimeStamp:0013ba7695698 Longitude:59a9f580 Latitude :eb76a140 Altitude:280 Angle:048 Speed:045 I…
Ranju
  • 17
  • 4
-5
votes
2 answers

How to simultaneously traverse Binary Tree using recursion and save key to array?

My code is to find a value in AVL tree that is strictly higher than the value inputted. I have tried to use inorder traversal approach it got stuck at saving data to array I'm trying to traverse my BST using recursion and also save data to an array…
-5
votes
1 answer

AVL and Red-Black Trees

I do not know how to do either of these problems. However, I did find example code for the AVL tree here: http://users.cis.fiu.edu/~weiss/dsaajava/code/DataStructures/AvlTree.java However, I still am unsure how to do this. Can someone please help me…
1 2 3
61
62