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

What are the pros and cons of multiclassing a Dragonborn Paladin with either Sorcerer or Warlock? and when and if to swap over [closed]

My Dragonborn Paladin is nearing the end of level 2, (Str3, Dex0, Con2, Int-1, Wis-1, Cha3, with Defensive giving AC19).

The main group I play with, he is the only Tank, unless my 10 year old daughter, joins in with her Circle of the moon Druid

She is the only child in the group and you can’t rely on her to focus on battle tactics 🙂

—————-new below ——————

My initial goal was to create a super paladin, I tend to play him as a tank with healing, saving my limited spell casting for just the right time due to limited spell slots, so I hardly ever use it. I once even died holding onto the valuable spell slots because I forgot about them.

However, once I started looking into it, I haven’t found that perfect sweet spot, that balances out the Spell Slinging Tank Front Man. All the options I’ve looked at have drawbacks that make me wonder if it is a combo that is worth pursuing

Just hoping for that splash of inspiration to make it all come together.

Can a Mystic swap out their Bonus Disciplines for some that aren’t from their Order?

The Mystic is an Unearthed Arcana class in D&D 5th Edition. All the Mystic Orders (subclasses) except the Soul Knife get Bonus Disciplines :

At 1st level, you learn two additional psionic disciplines of your choice. They must be chosen from among [your Order’s] disciplines.

Regular disciplines can be swapped out :

In addition, whenever you gain a level in this class, you can replace one discipline you know with a different one of your choice.

Can the Bonus Disciplines also be swapped out, even for replacements that aren’t from the Order ?

Is concept of virtual memory about memory isolation or about ability to swap? Or both?

Most reading I found about virtual memory, such as http://www.linux-tutorial.info/modules.php?name=MContent&pageid=89 or https://en.wikipedia.org/wiki/Virtual_memory always state that virtual memory is a concept that allows operating system to make it “appear as though you have more memory than you really do”.

But isn’t that what overcommit is about? Isn’t whole virtual memory concept primarily about the fact that each process has an isolated virtual memory pool, thus being unable to read or modify other process memory?

If not, what is this technology of memory isolation within own virtual memory pools called?

Do I need a separate swap partition for hibernation or I may use usual system swap partition?

I use Ubuntu 19.04.

I have not enough physical memory (only 8 GB), thus I regularly use swap partition to extend my virtual memory. (Swap partition size is ≈ 9 GB.)

And now I want to set up hibernation.

My question is: how am I supposed to set it all up, so that Ubuntu could save memory state to disk and not to overwrite my existing swap data?

Do I have to create a separate swap partition?

And what if currently (right in this second) my virtual memory usage is less than 8 GB, but some data is still saved in swap partition (e.g. memory usage is 4 GB of 8 (50%), but swap partition usage is 10%) – will I be able to hibernate using that swap partition right now?

How do I set it all up?

Lubuntu, broken fstab and non existent swap

I did a fresh install of Lubuntu desktop (meant as a headless machine mostly), with formatting the disk via installer.

Apparently it didn’t create a partition properly.. no GPT but msdos.

The machine wouldn’t boot to the main drive unless i unplugged the 2nd SATA drive (for storage). Remained stuck on HP bios.

The system is currently running, i have SSH access, but unfortunately won’t be physically accessing the machine for a while.

After hours of crawling the web for tutorials and discussions.. no success. I’ve only managed to trash the fstab, and obviously didnt make backup (not that it was any good..)

here are a few cmd returns :

/dev/sda1: UUID="1124c007-a2cd-4e2b-8942-06fca94f5f88" TYPE="ext4" PARTUUID="4ac38d5d-01" 


   NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT sda      8:0    0 596,2G  0 disk  └─sda1   8:1    0 596,2G  0 part / 


    Filesystem     1K-blocks    Used Available Use% Mounted on udev             1959572       0   1959572   0% /dev tmpfs             403696    1220    402476   1% /run /dev/sda1      614267120 5072576 577921748   1% / tmpfs            2018476       0   2018476   0% /dev/shm tmpfs               5120       4      5116   1% /run/lock tmpfs            2018476       0   2018476   0% /sys/fs/cgroup tmpfs             403692       4    403688   1% /run/user/1000 tmpfs             403692       0    403692   0% /run/user/117 

sudo parted -l

Model: ATA WDC WD6400BEVT-8 (scsi) Disk /dev/sda: 640GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags:   Number  Start   End    Size   Type     File system  Flags  1      1049kB  640GB  640GB  primary  ext4 

swapon -s returns nothing

How do i properly create a SWAP file with the current config (do i need one, how come the installer didn’t make it?)

And most importantly what should the fstab look like please? So i can safely reboot the machine via SSH without fear of it not booting where it needs to and then the machine staying idle for weeks..

Thanks in advance !

(what will i need to run to be safe, regarding GRUB or else?)

ps: after install i had the following error (fwiw)

cryptsetup: WARNING: The initramfs image may not contain cryptsetup binaries nor crypto modules. If that's on purpose, you may want to uninstall the 'crypsetup-initramfs' package in order to disable the cryptsetup initramfs integration and avoid this warning.

.. removed cryptsetup and then ran update-initramfs -u