what is the Balance factor in AVL tree - avl-tree

I'm making presentation for AVL tree, can't understand what is the balance factor.
please give me the link or any thing that I can understand graphically how height of an AVL tree's height effect

If I understood your question correctly.
Difference between the height of the left sub tree and right sub tree is the balance factor of an AVL tree.when the factor is 1,0, or -1 the tree is balanced otherwise unbalanced .
Play with AVL tree applet to get some intuition on this
See this link for Balance Factor

Related

Why don't react use red-black tree to shape its model?

Red-black tree is a kind of AVL tree which is widely used in data base for it is efficient in CRUD. Why react do not use it as its virtual DOM tree model? You'd better give me a mathematic proof.
I guess there is a reason that AVL tree is to make searching more quickly, but in UI area, we often concentrate on tree's diff and transform. But another question, is there a kind of data structure can make tree diff and transform more efficient?

HLSL circular/spiral transition shader

I am developing some shaders for WPF, and so far I managed to get fadeout, and swipe shader working, but for this one, I have no idea where to start.
Could someone please hand me out a few tips on how to approach this problem?
What I am trying to achieve is the following:
Thank you
In my opinion the easiest way to build any complicated effect is to decompose the original effect into small parts and add them together. In your case the effect consists of 3 parts:
5 rings filled after each other
each ring is filled counterclockwise from the left
the filling of a ring is a circle at each end
This in mind you can build a solution for each part separately and add the results together.
I assume that there will be a variable float progress; rolling from 0 to 1 which determines the progress of the transistion.
In following some starting points for each part:
For 1. you check the distance of the texture coordinate of the fragment to the center of the screen and divide the maximum distance into 5 parts. While the progress is 0 <= progress < 0.2, the first ring is visible, while 0.2 <= progress < 0.4 the second and so on.
For 2. you check the angle of the difference vector between the fragment and the center to the left vector, e.g. using atan2. Within each part (such as 0.0-0.2) you compare the local progress of the stage to the angle to determine the visibility, making the fragments appear in an angle dependent way.
The 3. might be the most tricky part, as you will have to construct the center of the progress ring ends and compute the distance to the fragment. If it is within the current ring thickness is is visible.
Hopefully this quick thoughts give you a rough starting point for your effect!

Insertion of same elements in Red-Black Tree?

How Red Black Tree will formed if we insert same elements, for example inserting 8,8,8,8,8,8,8 .
If you insert 8,8,8,8,8,8,8 it will be displayed something like below,
because Red-Black Tree follows these properties:
A red-black tree is a balanced binary search tree with the following properties:
Every node is colored red or black.
Every leaf is a NIL node, and is colored black.
If a node is red,
then both its children are black.
Every simple path from a node to a
descendant leaf contains the same number of black nodes.

Maximum-perimeter bounding rectangle for a set of points

I've been struggling for quite a while with this seemingly simple problem. I am given a set of points (which I have further simplified down to a convex hull) and my task is to find a rectangle (not necessarily axis-aligned) that encompasses all of them, has no extra space around (so that it is tight-fitting around the points) and has the maximum possible perimeter. It was no trouble for me to find the minimal one, but this has proven to be a tougher nut to crack. When searching for the minimal bounding rectangle, I was able to use the assumption that one of the rectangle's sides was always aligned with one of the hull's sides, but here I don't see any such case here. Am I missing something painfully obvious? The only way I could come up so far is to test antipodal pairs of points if they can project onto the sides of the rectangle and use some trig to maximize the function, but I just lost myself in the calculations.
Thanks in advance!
First, compute the convex hull of your point set.
Now, think about spinning the polygon around and computing the smallest enclosing axis-aligned rectangle. Notice that the top point, the left point, the right point, and the bottom point will proceed clockwise around the convex hull from one vertex to the next.
You can't try every possible angle explicitly. You can, however, do a sweep-line trick. Given an angle, though, you can compute the top, left, bottom, and right points after spinning the polygon by that angle as well as the first of the top, left, bottom, and right points to change identity as you continue rotating the polygon. So you get a range of angles for which your current choices of top, left, bottom, and right are correct; further, you know what the next correct choice of top, left, bottom, and right is.
For each legitimate choice of top, left, bottom, and right, You wind up having to compute the maximum value of a*sin(theta) + b*cos(theta) for fixed a and b over some range of theta. Recall from trig that a*sin(theta) + b*cos(theta) = sqrt(a^2+b^2) cos(theta - arctan(b/a)). You evaluate the function at the boundaries of your interval and where the derivative is zero (at arctan(b/a) plus any integer times pi) and you're golden.

Going from AVL trees to Red-Black trees

According to my book, coloring red links that go from nodes of even height to nodes of odd height in an AVL tree gives a (perfectly balanced) 2-3-4 tree, where red links are not necessarily left-leaning.
But I don't get how exactly. When I try it with some examples, I keep getting stuck. Can someone illustrate it for me please?

Resources