why swap function is use in union find algorithm? How rank or size array is used for optimization

void union_sets(int a, int b) {     a = find_set(a);     b = find_set(b);     if (a != b) {         if (size[a] < size[b])             swap(a, b);         parent[b] = a;         size[a] += size[b];     } } 

Q1.why we need this swapping? can’t we do like this without swapping

if (size[a] < size[b])          parent[a] = b;         size[b] += size[a];  

Q2.what is the difference between size array and rank array.Is Rank means the height of a node and size means no of node in that tree which contains this node

Does using links to other pages diliute the linking link juice/page rank?

There are lot’s of questions here about passing link juice to other pages, including Does how deep a page is in the page hierarchy affect it's ranking?. I’ve read several of them over the months, but I always come away wondering the same question.

Does linking to another page, dilute or burn some of the link juice the linking page has already earned? For example, if my current page has for example, a link juice of 10, and I link to another page, it passes a certain amount of juice (I’ll use 90% as an example) of the linking page’s juice, giving the page being linked to a .9 boost in it’s own link juice. However, does that mean the linking page’s page’s remaining juice is now less than 10?

While some of the questions would imply this to be the case, it seems counter intuitive as no one would ever want to link to any page outside of their own content for fear of losing page rank.

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$ nodes so $ c * f(n)\le rank(r)\le n-c*f(n) $ .

$ rank(r)$ gets his maximum value when his sub-left tree contains maximal number of nodes and because it’s an AVL tree, for tree with height $ h$ the sub left tree will be with height of $ h-1$ and the number of nodes will be maximal when the sub tree is a full tree with $ 2^{h-2}-1$ nodes hence we get:
$ rank(r)\leq 2^{h-2}-1+1=2^{h-2}$

On the other hand, $ rank(r)$ gets his minimal value when his sub left tree contains a minimal number of nodes and it happens when the sub left tree is a fibonacci tree with height of $ h-2$ , therefore
$ rank(r) \geq \phi ^{h-2}+1$ .

Now I need to find f as a function of the number of nodes $ n$ and not the height $ h$ . Am I in the right direction?
Would apricciate any help how to continue, Thanks.

Implementation of RANK

I am trying to implement the RANK function of SQL Server using only basic SQL functions. I managed to implement the DENSE_RANK function but I don’t know how extend it to RANK. More specifically, I don’t know how to arbitrarily distinsguish between rows of the same rank.

Here is my implementation of DENSE_RANK.

SELECT A.partition_id,     A.order_column_id,     (         SELECT SUM(CASE WHEN B.order_column_id > C.order_column_id THEN 1 ELSE 0 END)         FROM MyTable AS B         INNER JOIN MyTable AS C             ON C.partition_id = B.partition_id             AND C.partition_id = A.partition_id             AND C.order_column_id = A.order_column_id     ) + 1 AS rank     FROM MyTable AS A 

How can I write an implementation of RANK in a similar way?

Is there an option to circumvent creating an entry in the character advancement log in Genesis 6.1.2 when creating a hero rank >1 character?

When creating Splittermond player characters with Genesis 6.1.2, how do I create characters with a higher hero rank than 1? Currently, it looks like I have to create an event after regular hero rank 1 creation that awards my character experience points, and then use those to advance them.

Is there an option to circumvent that step as it creates an entry in the character advancement log which I’d like to circumvent.

When will rank

Hello. What could be happening?  I’ve been scraping with gsa for a month and a half and I can’t see my site on Google searches? … What can I be doing wrong?