Questions tagged [avl-trees]
The avl-trees tag has no usage guidance.
50
questions
0
votes
2
answers
56
views
AVL tree with balance factor equal to depth
If you were to define an altered AVL tree where the balance factor (the difference between the height of the left and right subtree) of a node must be less than or equal to the depth of the node (in ...
1
vote
2
answers
372
views
Ordered sequence with logarithmic insert and remove
Problem: we have a sequence of numeric values, e.g. [102, 25, 77, 17, 2, 13]. We need to implement 3 operations, each can be at most logarithmic time complexity.
<...
0
votes
0
answers
100
views
Number of ways to insert elements into an AVL tree such that there are no rotations
How many ways can we insert elements { 1, 2, 3, .... 7 } to make an AVL tree so that it does not have any rotation?
I broke it down into 2 cases:
Case 1: height of tree = 2, (a complete binary tree) ...
0
votes
1
answer
47
views
What does h indicate in this diagram of avl trees?
Looking at the tree on the left it seems that the triangles represent leaves of the avl tree. To arrive at the balancing of -2 besides the node y the right subtree must have 2 nodes while the left ...
2
votes
1
answer
78
views
Find a key in a BBST for which sum of values of keys smaller then it - is maximal
I'm required to describe an implementation of a data structure that holds key,value pairs, which can be signed integers.
We need to be able to init() in O(1), insert(x) in O(logn), delete(x) in O(logn)...
1
vote
0
answers
155
views
logarithmic height AVL trees
AVL trees are height balanced binary search trees. As a consequence of this balance, the height of an AVL tree is logaritmic in its number of nodes. Then, searching and updating AVL-trees can be ...
4
votes
1
answer
643
views
Big O vs. Big Theta for AVL tree operations
On the Wikipedia page for AVL trees, the time/space complexity for common operations is stated both for average case (in Big Theta) and worst case (in Big O) scenarios. I understand both Big O and Big ...
1
vote
1
answer
234
views
Interval Tree by Augmenting an AVL Tree
According to Wikipedia: An augmented tree can be built from a simple ordered tree, for example a binary search tree or self-balancing binary search tree, ordered by the 'low' values of the intervals. ...
0
votes
1
answer
436
views
Height of AVL Tree
I found an AVL tree implementation on the internet and experimented:
For a tree with node count of 2^20, the minimal and maximal tree heights are 16 and 24.
While these heights are lg(n)-ish, I am ...
0
votes
1
answer
348
views
AVL Tree rotations
What size is the largest AVL tree for which an insertion could trigger a double rotation?
-1
votes
1
answer
70
views
Are AVL&RB Trees without additional storage for balance information in each node feasible?
One advantage claimed for scapegoat trees over other balanced trees like AVL or red-black(RB trees - just mentioning AVL henceforth) is not needing to store additional balance information.
But can't ...
0
votes
0
answers
114
views
Rebalance the following AVL tree after inserting G. You need to show the middle step if it happens. Briefly explain the operations
I recently learned AVL Trees but I still lack a complete understanding of the concept. I understand that an AVL tree is a Binary search tree that checks for the height of the tree, but I still don't ...
2
votes
0
answers
141
views
How is red-black tree insertion more effective than avl tree insertion
I'm having trouble understanding why RB tree insertion is called more effective in all sources.
It's said that AVL trees require "more rotations" than RB trees, but from what I've learned I ...
0
votes
0
answers
54
views
Question about AVL properties
Assume that the oil company saves for each person that works in the
company a record with its name, its salary, its age and its date of
birth. You can assume that no two fields are identical for any ...
0
votes
0
answers
59
views
Minimum number of elements in AVL tree to make it worth creating
Given an AVL tree containing nodes ordered by unique integer I.D's and data as pointers to some struct, what would be the expected minimum number of elements that will justify the creation and ...
0
votes
0
answers
97
views
Suggest a Data Structure that support the following operations with time complexity O(log(n))
I’m looking for a data structure that supports that store the salaries of it’s employees.
Insert(e) – Insert employee e into the data structure.
AvgDecile(k) – Returns the average salary of the k’th ...
2
votes
2
answers
78
views
Self-balancing BST supporting in-order-sequential multi-insertions / multi-deletions in logn+klogk time?
Given a self-balancing binary search tree of size $n$, I want to perform the following operations:
InsertInOrderSequentialBatch an ordered sequence of $k$ values (...
0
votes
2
answers
304
views
AVL-tree insertion complexity proof
I tried to figure out the proof of insertion operation in AVL-tree is O(log n), but I do not know how.
I also tried to find it somewhere on the Internet, but I could not find any good results. Do you ...
1
vote
2
answers
601
views
is it possible to create an avl tree given any set of numbers?
I am studying balanced trees, especially AVL trees. My question is whether is it possible to create an avl tree given any set of numbers. is it possible to prove the following statement?
Let $A$ be ...
1
vote
1
answer
1k
views
Every AVL tree can be colored to be a red-black tree
I want to prove any AVL tree can be turnt into a red-black tree by coloring nodes appropriately.
Let $h$ be the height of a subtree of an AVL tree.
It is given that such a coloring is constrained by ...
2
votes
1
answer
2k
views
What exactly is the difference between a Balanced Binary Search Tree and an AVL tree?
I'm learning some Data Structures and I cannot figure out the difference between the Balanced BST and the AVL Tree. From my understanding, an AVL tree is a balanced tree with the height difference <...
1
vote
1
answer
172
views
proof non-empty AVL tree
The vertex of a binary tree is called an single child if it has a father's vertex but does not have a neighbor.
The root is not considered an single child.
let mark in numOnly a number of vertices ...
0
votes
0
answers
413
views
What is the maximal difference between the depths of 2 leaves in AVL tree?
I'm wondering what's the answer of the following question:
What is the maximal difference between the depths of 2 leaves in an AVL tree?
Intuitively I think that it shouldn't exceed $log n$ but have ...
3
votes
1
answer
2k
views
Worst Case for AVL Tree Balancing after Deletion
After deleting a node in an AVL tree, self-balancing (zig-zag rotation or the left-right balancing) maintains O(logn) time that is not guaranteed in other unbalanced trees (like BST).
The Balancing ...
0
votes
1
answer
776
views
Augmenting AVL tree to calculate sum of subtree
Suggest a way to augment an AVL tree to support a $O(\log n)$ implementation of the function
calculateSum(key), which receives a key of a node and returns the sum ...
2
votes
2
answers
168
views
Managing an hotel using AVL trees - Data Structures
I have a Data Structure question where I need to manage an hotel, each room has a number between $1-n$
and it can be occupied or not.
Available Data structures: AVL* Trees, B-Trees, Arrays, Stacks, ...
0
votes
1
answer
2k
views
Prove that AVL tree has this kind of property with Fibonacci sequence
Q: Prove that for any AVL tree that has $n$ nodes ($n\geq 1$)
and has a height of $h$ this property is true:
$n \geq F(h)$ where $F(h)$ is the $h$-th element in the Fibonacci sequence:
$F(0) =0, F(1)=...
0
votes
0
answers
14
views
Parsing text, then searching it: one entry per position, vs. 1 JSON column per text
I have a Rails application using Postgresql.
Texts get added to the application (ranging in size -- as short as a few words, to as long as, say, 5,000 words?).
The text gets parsed, both ...
0
votes
1
answer
664
views
Rank of root in AVL tree
Find a function that bounds from above and below (asymptotic) the rank of the root r in an AVL tree,
i.e. find a function $f(n)$ so there exists a constant $c>0$ that for every AVL tree with $n$ ...
1
vote
0
answers
1k
views
Find the median element of two AVL trees in $O(\log n)$
I'm attempting the problem of finding the median element in two AVL BST's in $O(\log n)$ time. In this problem, we are given two AVLs, with a combined size of $n$ (the distribution across the two ...
1
vote
1
answer
541
views
Efficiently finding the min-cost path of an AVL tree
It seems that in a full AVL tree, the left edge is always the minimum-cost path. For example, take the following full AVL tree:
The min-cost path would be 8-6-5. ...
3
votes
1
answer
287
views
Dynamic data structure that checks all prefix sums of a subsequence are >= 0 and sum is = 0
Lets consider sequences whose elements are $-1,0,1$.
Subsequence $A[i...j]$ is $good$ if sum of its elements $=0$.
Example: for sequence $1,1,0,-1,-1,1$ subsequence $1,0,-1,-1,1$ is $good$.
...
3
votes
1
answer
85
views
Structure for getting $| \{ a,b \} \subset S : a+b \le d|$ in O(1)
I am struggling with exercise from the old algorithmic exam:
$d$ is const for the whole structure.
Propose a structure for which you can do:
Init(S) //called only 1 time
Insert(x, S):: $ S := S \...
1
vote
1
answer
714
views
Why multiple rotations might be needed after deletion in an AVL tree if after insertion there can be at most one needed?
I understand that after deletion you have to retrace to update ancestors and after insertion you do the similar however at most one rotation will be performed.
The question is why is there the ...
0
votes
2
answers
2k
views
is AVL tree is better than heap for sorting purpose?
for sorting n elements what is better to use AVL tree or heap data structure and why? Can someone explain in brief?
1
vote
1
answer
3k
views
How to prove that in an AVL tree with height h, the depth of every leaf node is at least $\lceil h/2 \rceil$
I have an AVL tree with height h. I understand how to get h $\thickapprox$ 1.440 log N. However, I can't figure out how to calculate the minimum depth of a leaf node from root. I tried constructing a ...
0
votes
1
answer
79
views
AVL tree balance property states for the two subtrees of a node, their height can differ at most one. Why can't it be zero?
I was thinking that if they were equal, say they are required to be zero this would be enforce the balance property more effectively. Can anyone explain why 1 is a satisfactory rather than just them ...
-1
votes
1
answer
349
views
Is the following a AVL tree? [closed]
I have a tree as
Is it an AVL tree? it seems to balanced for me.
0
votes
0
answers
375
views
Finding rank of newly inserted node in AVL tree augmented with rank of node
My prof was talking about how to augment a tree to efficiently find the key with a given rank. On the way to getting the right answer (store the size of the subtree rooted at each node), he proposed ...
1
vote
1
answer
2k
views
AVL Tree - Print ascending using in-order
Trying to understand how to write proof of correctness.
Searched over the internet on how to write proof of correctness but can't find a good solution for it.
The following sorting algorithm is ...
2
votes
0
answers
379
views
Optimizing AVL Tree operations for sequential data
I'm working on an implementation of a data structure that needs a tree-like data structure for accelerating look-ups.
The interesting part about this data structure is that the only operations on the ...
0
votes
0
answers
613
views
How to create an AVL tree, given it's pre-order traversal?
Given the pre-order traversal, we can easily obtain the necessary Binary Search Tree(BST- not necessarily balanced). However, the problem arises when we have to decide the balancing manually(this was ...
1
vote
1
answer
236
views
Is it possible to balance a already constructed un-balanced AVL tree, with no prior information of last insert?
Im learning about tree data structures, and had a question that i couldnt find answer to so I came here.
Usually when we balance a tree, we insert keys and keep checking balance factor, as soon as it ...
3
votes
2
answers
4k
views
AVL tree worst case height proof
The worst case height of AVL tree is $1.44 \log n$. How do we prove that?
I read somewhere about Fibonacci quicks but did not understand it.
1
vote
1
answer
138
views
avl trees rotations question
As you can see in this tree its unbalanced at the root with a balanced factor of $-2$. You can also perform a Right left rotation or a Right Right rotation. Which do you have to pick in this case?
0
votes
0
answers
130
views
How many maximum height AVL trees given height?
I am having some trouble finding a recursive formula for finding the number of maximum height AVL trees of height h. Height 0 has 1, height 1 has 2, height 2 has 4, height 3 has 8, etc. is that ...
2
votes
3
answers
1k
views
How do I know which direction I should rotate a node in an AVL Tree?
I'm studying AVL Trees in my programming class and we got this exercise dealing with right, left, left-right and right-left rotations as a way to check if we understand the theoretical concept of AVL ...
1
vote
1
answer
99
views
AVL Rotations Abbreviations
I read that there are 4 types of rotations:
Left rotation
Right rotation
Left-Right rotation
Right-Left rotation
What are the corresponding abbreviations: RL,LR,RR,LL? Is there a reference how to ...
10
votes
4
answers
6k
views
Don't understand one step for AVL tree height log n proof
I came across a proof that an AVL tree has $O(\log n)$ height and there's one step which I do not understand.
Let $N_h$ represent the minimum number of nodes that can form an AVL tree of height $h$. ...
22
votes
1
answer
5k
views
AVL trees are not weight-balanced?
In a previous question there was a definition of weight balanced trees and a question regarding red-black trees.
This question is to ask the same question, but for AVL trees.
The question is, ...