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
6
votes
5 answers

Choosing a Data structure for very large data

I have x (millions) positive integers, where their values can be as big as allowed (+2,147,483,647). Assuming they are unique, what is the best way to store them for a lookup intensive program. So far i thought of using a binary AVL tree or a hash…
Carlos
  • 5,256
  • 19
  • 64
  • 113
6
votes
2 answers

Difference between the time complexity required to build Binary search tree and AVL tree?

While I was learning Binary search tree(Balanced and unbalanced), I come up with questions which I need to resolve: If I construct a Binary search tree(Not necessary to be balanced) , using n elements then what is the total time complexity for tree…
6
votes
2 answers

weight-unbalanced AVL tree

Believing the wikipedia article: http://en.wikipedia.org/wiki/AVL_tree AVL trees are height-balanced, but in general not weight-balanced nor μ-balanced;[4] that is, sibling nodes can have hugely differing numbers of descendants. But, as an AVL…
taktak004
  • 634
  • 7
  • 26
6
votes
1 answer

A sequence that forms the same AVL and splay trees?

Is there such a sequence of numbers (1-7, all numbers used, only once each), that would form equal AVL and splay tree?
6
votes
2 answers

What is the minimum sized AVL tree where a deletion causes 2 rotations?

It is well known that deletion from an AVL tree may cause several nodes to eventually be unbalanced. My question is, what is the minimum sized AVL tree such that 2 rotations are required (I'm assuming a left-right or right-left rotation is 1…
Greg C
  • 61
  • 1
  • 3
6
votes
1 answer

AVL Trees: How to do index access?

I noticed on the AVL Tree Wikipedia page the following comment: "If each node additionally records the size of its subtree (including itself and its descendants), then the nodes can be retrieved by index in O(log n) time as well." I've googled and…
5
votes
1 answer

How to generate an AVL tree as lopsided as possible?

I saw this in some paper and someone argued that there can be at most log(n) times rotation when we delete a node of an AVL tree. I believe we can achieve this by generating an AVL tree as lopsided as possible. The problem is how to do this. This…
Yuming Cao
  • 807
  • 1
  • 10
  • 22
5
votes
1 answer

Preference between an AVL tree and a 2-3 tree

can someone tell me if using an AVL is preferred over using a 2-3 tree or vice-versa and why so? Thx
Melvic
  • 51
  • 1
  • 4
5
votes
5 answers

How to implement insertion for AVL tree without parent pointer?

I saw some articles about the implementation of AVL's rebalance() function. After each insertion, we should check the insertion Node's ancestors for balance. So I think, in order to check ancestors' balance, I got to know the insertion Node's…
Alcott
  • 15,679
  • 24
  • 106
  • 170
5
votes
1 answer

AVL tree dictionary

So far I've been drawing up a plan of attack to see how I could go about doing this and this is what I have: bool isEmpty() const - returns true if empty, false if not int getSize() - returns how many words are stored in the dictionary void insert…
user814447
5
votes
2 answers

Merging 2 DIFFERENT AVL trees

Assume that I have two AVL trees and that I know their respective sizes. However, I don't know if there are repeated nodes, or any other information. What would be the most efficient way to merge them in a new AVL tree? The original trees can be…
Josep
  • 12,515
  • 2
  • 39
  • 44
5
votes
2 answers

What does the AVL stand for in AVL tree?

An AVL tree is the same as a self-balancing binary search tree. What does AVL stand for? Does it have to do with the name of the inventor?
Jing Ma
  • 119
  • 2
  • 10
5
votes
4 answers

C# Most efficient data structure to insert and to remove lower half

Imagine I have a big sorted list of integers (>1000 items). I need to be able to do two operations on this list: remove the lower half and fill the list again to its original size by inserting random integers. Because I do these operations about a…
Safron
  • 569
  • 7
  • 20
5
votes
2 answers

Height difference between leaves in an AVL tree

What is the maximum difference between any two leaves in an AVL tree? If I take an example, my tree becomes unbalanced, if the height difference is more than 2(for any two leaves), but the answer is the difference can be any value. I really don't…
5
votes
2 answers

Paged binary trees vs. AVL trees and/or B-trees

How are paged binary trees different from AVL trees and/or B-trees?
neuromancer
  • 47,047
  • 74
  • 161
  • 217
1 2
3
56 57