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.

842 questions
-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

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
  • 37,353
  • 77
  • 251
  • 478
-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
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
  • 801
  • 1
  • 10
  • 24
-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 ?
-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
  • 411
  • 1
  • 5
  • 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
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…
-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…
MrCalc
  • 53
  • 6
-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
  • 417
  • 4
  • 24
-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…
-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
1 2 3
56
57