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

Debugging a Map backed by an AVL tree?

This is one of three trees I am using to parse text and print out every unique word, the line numbers it appears on, and the number of times it appears. I have already used a hash and tree map and have both of them working correctly. My instructor…
waltershc
  • 23
  • 4
0
votes
2 answers

implementation of AVL tree toString()

This is my toString() but it doesn't work properly public String toString() { StringBuilder str = new StringBuilder("{"); traverse(root, str); str.append("}"); return str.toString(); } private void…
kaboom
  • 833
  • 4
  • 18
  • 38
0
votes
3 answers

Logarithmic condition of AVL Tree

For my AVL Tree implementation, I have a node which has a left, right and parent pointer, and a balance variable. Each time I am inserting a new node and carrying out the required rotation, I am updating the balance by subtracting the right sub-tree…
chris05
  • 735
  • 4
  • 13
  • 27
0
votes
1 answer

Inheriting from a class with a private inner classes C++

So I have an assignment in which I need to use a rank binary tree. I've already implemented a template AVL tree (C++) a while back so I thought of using it as a basis and adding to it. Since I don't want to duplicate code and work with what I have,…
matanc1
  • 6,525
  • 6
  • 37
  • 57
0
votes
1 answer

Binary Search Trees: Height of a node in an AVL tree

Here is my AVL tree that I had to make (hopefully large enough to see clearly) http://oi46.tinypic.com/2426fer.jpg I know my tree is correct for what I had to do, but I am unsure about the height of the AVL tree and how that works, as you can…
0
votes
1 answer

Drawing Binary trees (AVL and Red-black trees)

I don't understand how to do this, can someone please help. I need to insert the following keys into an empty AVL tree and show the tree after each insertion. The keys should be taken as strings of characters not as months. For example, Jul <…
0
votes
1 answer

AVL tree - manual drawing and printing

Is there any program/app that draws and save avl tree charts ? To pdf format preferably
user1608920
  • 157
  • 2
  • 9
0
votes
1 answer

Adding to an AVL tree

When I am adding a value to an AVL tree, how do I know where to insert it? I'm not talking about the coding aspect, but more of a pictorial representation. I'm assuming the insertion is done at the first available external node, but I'm unsure, as…
jsan
  • 1,047
  • 8
  • 20
  • 33
0
votes
3 answers

Representing an AVL Tree graphically

I implemented and AVL tree using C++, at the moment I print the AVL tree to the console but I need to represent the tree using GUI as part of an application the user can use to interact with the tree. what libraries etc. should I look into in order…
Samantha Catania
  • 5,116
  • 5
  • 39
  • 69
0
votes
1 answer

In-memory tree/index structure for fast lookups and insertions of increasing integer keys

Background: I'm going to be inserting about a billion key value pairs. I need an in-memory index with which I can simultaneously do look ups for the (32 bit integer) value for a (unique, 64 bit integer) key. There's no updating, no deleting and no…
Max
  • 2,760
  • 1
  • 28
  • 47
0
votes
1 answer

Can't rotate about the pivot

I am trying to insert a new value into an AVL tree. The new insertion causes imbalance (as per the article on Wikipedia, this should belong to the left-right case), hence needs rotation. However, it is not possible to rotate in the current…
SexyBeast
  • 7,913
  • 28
  • 108
  • 196
0
votes
0 answers

AVL Tree Sentinel

I am trying to finish a school project with AVL trees. What happens is that once I insert the root as well as two other nodes everything is ok, the program fails if I try adding any more than those three nodes. I figured that the problem was the…
Lane Fujikado
  • 135
  • 1
  • 3
  • 11
0
votes
1 answer

deleting an element in AVL trees in C

struct node *delete(struct node *root, int key) { struct node *remove_node; if (root == NULL){ return root; } if ( key < root->key) { root->left = delete(root->left, key); } else if ( key > root->key) { …
ms. sakura
  • 201
  • 1
  • 4
  • 11
0
votes
1 answer

Worst Case number of rotations for BST to AVL algorithm?

I have a basic algorithm below and I know that the worst case input BST is one that has degenerated to a linked list from inserts to only one side. How would I compute the worst case complexity in terms of number of rotations for this BST to AVL…
user595334
0
votes
2 answers

AVL Tree in C++ - Stack Overflow Exception

I'm writing an AVL tree program in C++. I'm basing it off of a BST Priority Queue program I previously made. Unfortunately every time a new node is added that should cause a rotation, a stack overflow exception is thrown. Here's my code thus…
o_man
  • 1
  • 1