Proving AVL trees can have children whose number of nodes aren't Θ of one another - algorithm

Let T be an AVL tree whose left subtree is TL and whose right subtree is TR. Let's let |TL| and |TR| be the number of nodes in the left and right subtrees, respectively.
I need to prove that neither |TR| ≠ Θ(|TR|) and vice-versa but I don't know how. I assume it has to do with the case where one tree is a full AVL tree and the other is a minimal AVL tree (a Fibonacci tree), but I don't know what to do from there.

In an AVL tree of height h, the number of nodes ranges between Fh+2 - 1 and 2h - 1. This first quantity is Θ(φh) and the second is Θ(2h), where φ is the golden ratio, approximately 1.61. This means that you can construct AVL trees where the number of nodes in the left subtree is Θ(φh) and the right subtree is Θ(2h), meaning that the left subtree has asymptotically fewer nodes than the right subtree. You can then reverse left and right to show that the right subtree can't be Θ of the left subtree either.
Hope this helps!

Related

Finding the number of nodes in 2-3 tree while left sub-tree of the root has 3 children,right sub-tree of the root has 2 children

Suppose there is a 2-3 tree with n nodes.
Each node in the left sub-tree of the root has 3 children. (except the leaves).
Each node in the right sub-tree of the root has 2 children. (except the leaves).
How am I supposed to find how many nodes exist in the right/left sub-tree of the root?
Denote n':= nodes number in the right root sub-tree.
Then,Nodes number in the left root sub-tree is (n-1)-n'.
How am I supposed to find n' (to write n' as an expression of n)?
I am a little bit confused.
Thanks !
Let the total height of the tree be h. Since it's a 2-3 tree, both the left and right subtree have heigth h−1. The number of nodes in the right subtree is 2^h − 1, and the number of nodes in the left subtree is (3^h − 1)/2. Beyond that, I don't know anything really interesting to say. The quotient nʹ / n doesn't come out very pretty, but it approaches zero quite quickly as h increases.

Is it possible to determine AVL tree balanced or not if instead of height depth is given?

In question it is given we can use depth only and not height.
(As we know for height we can say if difference between height of left subtree and height of right subtree is is at most one then it will be balanced)
Using depth can we find a way to prove tree balanced or not?
I tried by finding relation between different depth trees
What I got is that
If depth max = n
Then there must be n nodes whose depth is n-1
But this is just one condition I got.
It is not sufficient condition
( You can ignore my approach and try other thing .As there is no condition on approaching the problem)
The principle is the same as with height: use the following logic:
For each node do:
Get the maximum among the depths of all the nodes in the left subtree. Default (when no left subtree is present) is the current node's depth.
Get the maximum among the depths of all the nodes in the right subtree. Default (when no right subtree is present) is the current node's depth.
The difference between these two should not be more than 1.
If you implement this with a post-order traversal through the tree, you can keep track of the maximum depths -- needed in the first two steps -- as you traverse the tree.

Why A Balanced Binary Search Tree's Subtrees Cant Differ More than 1 In Height

Can anyone mathematically prove me why the following BST definition is always true by using the fact that the height of a BST is always logN where N is the number of nodes.
"a binary tree in which the left and right subtrees of every node differ in height by no more than 1."

Determine whether a subtree of a red-black tree has at most 3n/4 nodes?

I have a red-black tree with n nodes, rooted at x. How can I prove or disprove that the number of nodes in the left subtree of x (including the root of x.left) is at most 3n / 4 without counting?
You can just construct a counter-example with as many red nodes as possible on the left, and no red nodes at all on the right.
If the right is a complete all black tree with 2^h-1 nodes, and the left can be a complete tree with 2^(2h)-1 nodes.
When h>=3 the left side has more than 3n/4 nodes.

Find a vertex of size k in an AVL tree

Let a be an AVL tree with n vertices.
Each vertex has an extension representing the size of its sub-tree with the vertex himself as a root. I'm trying to implement an algorithm that gets as input a number k s.t. 1<=k<=n and return a vertex of size k in O(logn).
If the tree is a full binary tree it's easy we can just go right/left until we reach the node with the size we need since all nodes in a height h will have the same size. But when the tree is not full i'm getting stuck.
Any help will be much appreciated.
Thanks in advance!
P.S. I assume that each vertex has a different value.
First you check if the left sub-tree is bigger than k, if it is -> continue searching in it.
Otherwise, check if the left sub tree's size + 1 equals k, in that case the current element is the kth so return the current node.
If we've reached this point it means that the the kth element will be in the right sub-tree, so move on to the right sub-tree and search for the k - (left sub tree size + 1) element, since we've eliminated all those nodes already.

Resources